1 package myorg.relex.one2manybi;
2
3 import java.util.Date;
4
5 import javax.persistence.*;
6
7
8
9
10 @Entity
11 @Table(name="RELATIONEX_LOAN")
12 public class Loan {
13 @Id @GeneratedValue
14 private int id;
15
16 @ManyToOne(fetch=FetchType.LAZY, optional=false)
17 @JoinColumn(name="BORROWER_ID")
18 private Borrower borrower;
19
20 @Temporal(TemporalType.DATE)
21 @Column(nullable=false)
22 private Date checkout;
23 @Temporal(TemporalType.DATE)
24 private Date checkin;
25
26 public Loan() {}
27 public Loan(Borrower borrower) {
28 this.borrower=borrower;
29 this.checkout=new Date();
30 }
31
32 public int getId() { return id; }
33 public boolean isOut() { return checkin==null; }
34
35 public Borrower getBorrower() { return borrower; }
36 public void setBorrower(Borrower borrower) {
37 this.borrower = borrower;
38 }
39
40 public Date getCheckout() { return checkout; }
41 public void setCheckout(Date checkout) {
42 this.checkout = checkout;
43 }
44
45 public Date getCheckin() { return checkin; }
46 public void setCheckin(Date checkin) {
47 this.checkin = checkin;
48 }
49 }