Last active
January 12, 2022 17:45
-
-
Save 3gcodes/0bb0668843761c195a3c0f9fedec11a4 to your computer and use it in GitHub Desktop.
This file contains 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 | |
public class Organization { } | |
@Entity | |
public class Person { } | |
@Entity | |
public class OrgPerson { | |
@ManyToOne | |
@JoinColumn(name = "org_id") | |
private Organization organization; | |
@ManyToOne | |
@JoinColumn(name = "person_id") | |
} | |
public class SomeService { | |
public save(String orgId, String personId) { | |
// validate orgId and personId exists with Repository.existsById() | |
var orgPerson = new OrgPerson(orgId, personId); | |
orgPersonRepos.save(orgPerson) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment