1 19 import java.util.Set ; 20 import javax.persistence.CascadeType; 21 import javax.persistence.Entity; 22 import javax.persistence.GeneratedValue; 23 import javax.persistence.GenerationType; 24 import javax.persistence.Id; 25 import javax.persistence.OneToMany; 26 27 @Entity 28 public class Department implements java.io.Serializable { 29 30 private Long id; 31 private Set <Employee> employees; 32 33 public Department() { 34 } 35 36 @Id 37 @GeneratedValue(strategy = GenerationType.AUTO) 38 public Long getId() { 39 return id; 40 } 41 42 public void setId(Long id) { 43 this.id = id; 44 } 45 46 @OneToMany(mappedBy="department", targetEntity="Employee") 47 public Set getEmployees() { 48 return employees; 49 } 50 51 public void setEmployees(Set employees){ 52 this.employees = employees; 53 } 54 55 } 56 | Popular Tags |