Last active
September 6, 2021 14:41
-
-
Save Sutil/4b6dcff771ee2771cc712543291e29d5 to your computer and use it in GitHub Desktop.
@onetomany unidirectional examplo usint Spring JPA.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@OneToMany unidirectional examplo usint Spring JPA. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
class Child { | |
@Id | |
private String id; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
class Father { | |
@Id | |
private String id; | |
@OneToMany(cascade = CascadeType.ALL) | |
@JoinColumn(name = "fatherId", nullable = false) | |
private List<Child> children; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
public class FatherService { | |
private final FatherRepository fatherRepository; | |
public Father create(Father father) { | |
return this.fatherRepository.save(father); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment