1 package ejava.examples.orm.rel.composite; 2 3 import java.util.ArrayList; 4 import java.util.Collection; 5 6 import javax.persistence.*; 7 8 @Entity @Table(name="ORMREL_HOUSE") 9 public class House { 10 @Id @GeneratedValue 11 private int id; 12 13 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, 14 fetch=FetchType.LAZY, mappedBy="house") 15 private Collection<Room> rooms=new ArrayList<Room>(); 16 17 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, 18 fetch=FetchType.LAZY, mappedBy="house") 19 private Collection<Door> doors=new ArrayList<Door>(); 20 21 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, 22 fetch=FetchType.LAZY, mappedBy="house") 23 private Collection<Resident> residents=new ArrayList<Resident>(); 24 25 @OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, 26 fetch=FetchType.LAZY, mappedBy="house") 27 private Collection<Mortgage> mortgages=new ArrayList<Mortgage>(); 28 29 public House() {} 30 public House(int id) { this.id=id; } 31 32 public int getId() { return id; } 33 34 public Collection<Room> getRooms() { return rooms; } 35 public Collection<Door> getDoors() { return doors; } 36 public Collection<Resident> getResidents() { return residents; } 37 public Collection<Mortgage> getMortgages() { return mortgages; } 38 }