1 package ejava.examples.orm.rel.composite;
2
3 import javax.persistence.*;
4
5
6
7
8
9 @Entity @Table(name="ORMREL_DOOR")
10 public class Door {
11 @EmbeddedId
12 @AttributeOverrides({
13 @AttributeOverride(name="houseId", column=@Column(name="HOUSE_ID")),
14 @AttributeOverride(name="doorId", column=@Column(name="DOOR_ID"))
15 })
16 private DoorPK pk;
17
18 @ManyToOne(fetch=FetchType.LAZY, optional=false)
19
20 @JoinColumn(name="HOUSE_ID", insertable=false, updatable=false)
21 private House house;
22
23 public Door() {}
24 public Door(House house, int doorId) {
25 pk=new DoorPK(house.getId(), doorId);
26 this.house=house;
27 }
28
29 public DoorPK getPk() { return pk; }
30 public House getHouse() { return house; }
31 }