View Javadoc
1   package ejava.examples.daoex.bo;
2   
3   import java.util.Date;
4   
5   import javax.persistence.GeneratedValue;
6   import javax.persistence.Column;
7   import javax.persistence.GenerationType;
8   import javax.persistence.Id;
9   import javax.persistence.SequenceGenerator;
10  import javax.persistence.Table;
11  
12  @javax.persistence.Entity(name="jpaAuthor")
13  @Table(name="DAO_AUTHOR")
14  @SequenceGenerator(name="AUTHOR_SEQUENCE", sequenceName="AUTHOR_SEQ")
15  public class Author {
16      @Id
17      @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="AUTHOR_SEQUENCE")
18      @Column(name="AUTHOR_ID", nullable=false)
19      private long id;
20      
21      @Column(name="VERSION", nullable=false)
22      private long version=0;
23  
24      @Column(name="FIRST_NAME", length=32)
25      private String firstName;
26  
27      @Column(name="LAST_NAME", length=32)
28      private String lastName;
29  
30      @Column(name="SUBJECT", length=32)
31      private String subject;
32  
33      @Column(name="PUBLISH_DATE")
34      private Date publishDate;
35      
36      public Author() {}        
37      public Author(long id) {
38          this.id = id;
39      }    
40      
41      public long getId() {
42          return id;
43      }
44      @SuppressWarnings("unused")
45      private void setId(long id) {
46          this.id = id;
47      }    
48      public String getFirstName() {
49          return firstName;
50      }
51      public void setFirstName(String firstName) {
52          this.firstName = firstName;
53      }    
54      public String getLastName() {
55          return lastName;
56      }
57      public void setLastName(String lastName) {
58          this.lastName = lastName;
59      }    
60      public Date getPublishDate() {
61          return publishDate;
62      }
63      public void setPublishDate(Date publishDate) {
64          this.publishDate = publishDate;
65      }    
66      public String getSubject() {
67          return subject;
68      }
69      public void setSubject(String subject) {
70          this.subject = subject;
71      }    
72      public long getVersion() {
73          return version;
74      }
75      public void setVersion(long version) {
76          this.version = version;
77      }
78      
79      public String toString() {
80          StringBuilder text = new StringBuilder();
81          text.append(super.toString());
82          text.append(", id=").append(id);
83          text.append(", fn=").append(firstName);
84          text.append(", ln=").append(lastName);
85          text.append(", subject=").append(subject);
86          text.append(", pdate=").append(publishDate);
87          text.append(", version=").append(version);
88          return text.toString();
89      }
90  }