Skip to content

Instantly share code, notes, and snippets.

@nemo83
Last active December 15, 2015 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo83/5276313 to your computer and use it in GitHub Desktop.
Save nemo83/5276313 to your computer and use it in GitHub Desktop.
@Entity
public class Project {
@Id
private long id;
...
@OneToMany
private List<ProjectAssociation> employees;
...
// Add an employee to the project.
// Create an association object for the relationship and set its' data.publicvoid addEmployee(Employee employee, boolean teamLead) {
ProjectAssociation association =new ProjectAssociation();
association.setEmployee(employee);
association.setProject(this);
association.setEmployeeId(employee.getId());
association.setProjectId(this.getId());
association.setIsTeamLead(teamLead);
employees.add(association);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment