1 package ejava.examples.orm.rel.annotated;
2
3 import javax.persistence.*;
4
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7
8
9
10
11
12
13
14
15 @Entity @Table(name="ORMREL_APPLICANT")
16 public class Applicant {
17 private static Logger log = LoggerFactory.getLogger(Applicant.class);
18 @Id @GeneratedValue
19 private long id;
20
21 @OneToOne(optional=false)
22 @JoinColumn(name="APP_PERSON")
23 private Person identity;
24
25 @OneToOne(optional=true)
26 @JoinColumn(name="APP_BORROWER")
27 private Borrower borrower;
28
29 public Applicant() {
30 log.info("{}, ctor()", myInstance()); }
31
32 public long getId() { return id; }
33
34 public Borrower getBorrower() { return borrower; }
35 public void setBorrower(Borrower borrower) {
36 this.borrower = borrower;
37 }
38
39 public Person getIdentity() { return identity; }
40 public void setIdentity(Person identity) {
41 this.identity = identity;
42 }
43
44 private String myInstance() {
45 String s=super.toString();
46 s = s.substring(s.lastIndexOf('.')+1);
47 return s;
48 }
49
50 public String toString() {
51 return myInstance() +
52 "id=" + id +
53 ", identity=" + ((identity==null) ? "null" : identity.getId()) +
54 ", borrower=" + ((borrower==null) ? "null" : borrower.getId());
55 }
56
57 }