KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > examples > entitybean > Employee


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: Employee.java 9 2006-02-19 18:53:32Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.examples.entitybean;
27
28 import javax.persistence.Entity;
29 import javax.persistence.Id;
30 import javax.persistence.Table;
31
32 /**
33  * Define an employee with an id and a name.
34  * @author Florent Benoit
35  */

36 @Entity
37 @Table(name = "EMPLOYEES")
38 public class Employee implements java.io.Serializable JavaDoc {
39
40     /**
41      * Id for serializable class.
42      */

43     private static final long serialVersionUID = -2366200007462547454L;
44
45     /**
46      * Id of this employee.
47      */

48     private int id;
49
50     /**
51      * Name of the employee.
52      */

53     private String JavaDoc name;
54
55     /**
56      * Gets the Id of the employee.
57      * @return the id of the employee.
58      */

59     @Id
60     public int getId() {
61         return id;
62     }
63
64     /**
65      * Sets id of the employee.
66      * @param id the id's employee
67      */

68     public void setId(final int id) {
69         this.id = id;
70     }
71
72     /**
73      * Sets the name.
74      * @param name of employee.
75      */

76     public void setName(final String JavaDoc name) {
77         this.name = name;
78     }
79
80     /**
81      * Gets the name of the employee.
82      * @return name of the employee.
83      */

84     public String JavaDoc getName() {
85         return name;
86     }
87
88     /**
89      * Computes a string representation of this employee.
90      * @return string representation.
91      */

92     @Override JavaDoc
93     public String JavaDoc toString() {
94         StringBuilder JavaDoc sb = new StringBuilder JavaDoc();
95         sb.append("Employee[id=").append(id).append(", name=").append(getName()).append("]");
96         return sb.toString();
97     }
98
99 }
100
Popular Tags