1 package ejava.examples.orm.rel.composite;
2
3 import javax.persistence.*;
4
5
6
7
8
9 @Entity @Table(name="ORMREL_RESIDENT")
10 @IdClass(ResidentPK.class)
11 @AttributeOverrides({
12 @AttributeOverride(name = "residentId", column=@Column(name="RESIDENT_ID"))
13 })
14 public class Resident {
15 @Id
16 @ManyToOne(fetch=FetchType.LAZY, optional=false)
17 @JoinColumn(name="HOUSE_ID", nullable=false)
18 private House house;
19
20 @Id
21 private int residentId;
22
23 public Resident() {}
24 public Resident(House house, int residentId) {
25 this.house=house;
26 this.residentId=residentId;
27 }
28
29 public House getHouse() { return house; }
30 public int getResidentId() { return residentId; }
31 }