View Javadoc

1   /**
2   Copyright (C) 2007  <name of author>
3   
4   This program is free software: you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation, either version 3 of the License, or
7   (at your option) any later version.
8   
9   This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU General Public License for more details.
13  
14  You should have received a copy of the GNU General Public License
15  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17  package org.in2.simpleBoard.model;
18  
19  import java.io.Serializable;
20  import java.math.BigInteger;
21  import java.util.Date;
22  import javax.persistence.Column;
23  import javax.persistence.Entity;
24  import javax.persistence.GeneratedValue;
25  import javax.persistence.GenerationType;
26  import javax.persistence.Id;
27  import javax.persistence.JoinColumn;
28  import javax.persistence.Lob;
29  import javax.persistence.ManyToOne;
30  import javax.persistence.NamedQueries;
31  import javax.persistence.Table;
32  import javax.persistence.Temporal;
33  import javax.persistence.TemporalType;
34  
35  @Entity
36  @Table(name = "board")
37  @NamedQueries({})
38  public class Board implements Serializable {
39      private static final long serialVersionUID = 1L;
40      @Id
41      @Column(name = "id", nullable = false)
42      private Long id;
43      @Lob
44      @Column(name = "text", nullable = false)
45      private String text;
46      @Column(name = "date", nullable = false)
47      @Temporal(TemporalType.TIMESTAMP)
48      private Date date;
49      
50      @Column(name = "id_parent_board")
51      private Long idParentBoard;
52      
53      @Column(name = "id_user", nullable = true)
54      private Long idUser;
55      
56      @Column(name = "id_category", nullable = true)
57      private Long idCategory;
58  
59      public Board() {
60      }
61  
62      public Board(Long id) {
63          this.id = id;
64      }
65  
66      public Board(Long id, String text, Date date) {
67          this.id = id;
68          this.text = text;
69          this.date = date;
70      }
71  
72      @Id @GeneratedValue(strategy = GenerationType.AUTO)
73      public Long getId() {
74          return id;
75      }
76  
77      public void setId(Long id) {
78          this.id = id;
79      }
80  
81      public String getText() {
82          return text;
83      }
84  
85      public void setText(String text) {
86          this.text = text;
87      }
88  
89      public Date getDate() {
90          return date;
91      }
92  
93      public void setDate(Date date) {
94          this.date = date;
95      }
96  
97      public Long getIdParentBoard() {
98          return idParentBoard;
99      }
100 
101     public void setIdParentBoard(Long idParentBoard) {
102         this.idParentBoard = idParentBoard;
103     }
104 
105     public Long getIdUser() {
106         return idUser;
107     }
108 
109     public void setIdUser(Long idUser) {
110         this.idUser = idUser;
111     }
112 
113     public Long getIdCategory() {
114         return idCategory;
115     }
116 
117     public void setIdCategory(Long idCategory) {
118         this.idCategory = idCategory;
119     }
120 
121     @Override
122     public int hashCode() {
123         int hash = 0;
124         hash += (id != null ? id.hashCode() : 0);
125         return hash;
126     }
127 
128     @Override
129     public boolean equals(Object object) {
130         // TODO: Warning - this method won't work in the case the id fields are not set
131         if (!(object instanceof Board)) {
132             return false;
133         }
134         Board other = (Board) object;
135         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
136             return false;
137         }
138         return true;
139     }
140 
141     @Override
142     public String toString() {
143         return "org.appfuse.tutorial.model.Board[id=" + id + "]";
144     }
145 
146 }