KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > entity > book > Book


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Book.java 465 2006-05-18 14:50:37Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.tests.common.ejbs.entity.book;
27
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.Table;
31
32
33 /**
34  * Defines a book with its name, id and author.
35  * @author Gisele Pinheiro Souza
36  * @author Eduardo Studzinski Estima de Castro
37  *
38  */

39 @Entity
40 @Table(name = "BOOK")
41 public class Book implements java.io.Serializable JavaDoc {
42
43     /**
44      * The version value.
45      */

46     private static final long serialVersionUID = 1350259495852814154L;
47
48     /**
49      * Book Id.
50      */

51     private int id;
52
53     /**
54      * Name of the book.
55      */

56     private String JavaDoc name;
57
58     /**
59      * The book author.
60      */

61     private String JavaDoc author;
62
63     /**
64      * Default constructor.
65      */

66     public Book(){
67     }
68
69     /**
70      * Parametrized constructor.
71      * @param id book id
72      * @param name book name
73      * @param author the book author
74      */

75     public Book(final int id, final String JavaDoc name, final String JavaDoc author){
76         setId(id);
77         setName(name);
78         setAuthor(author);
79     }
80
81     /**
82      * Gets the book Id.
83      * @return the id of the book.
84      */

85     @Id
86     public int getId() {
87         return id;
88     }
89
90     /**
91      * Sets book Id.
92      * @param id the id's book
93      */

94     public void setId(final int id) {
95         this.id = id;
96     }
97
98     /**
99      * Sets the name.
100      * @param name of book.
101      */

102     public void setName(final String JavaDoc name) {
103         this.name = name;
104     }
105
106     /**
107      * Gets the book name.
108      * @return name of the book.
109      */

110     public String JavaDoc getName() {
111         return name;
112     }
113
114     /**
115      * Computes a string representation of this book.
116      * @return string representation.
117      */

118     @Override JavaDoc
119     public String JavaDoc toString() {
120         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
121         sb.append("Book[id=").append(id).append(", name=").append(getName()).append("]");
122         return sb.toString();
123     }
124
125     /**
126      * Gets the book author.
127      * @return the author name.
128      */

129     public String JavaDoc getAuthor() {
130         return author;
131     }
132
133     /**
134      * Sets the book author.
135      * @param author the author name.
136      */

137     public void setAuthor(final String JavaDoc author) {
138         this.author = author;
139     }
140
141 }
142
Popular Tags