KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > foedeployer > ejb > o2mb > EmployeeBean


1 /*
2 * JBoss, the OpenSource EJB server
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.test.foedeployer.ejb.o2mb;
8
9 import javax.ejb.EntityBean JavaDoc;
10 import javax.ejb.EntityContext JavaDoc;
11 import javax.ejb.FinderException JavaDoc;
12 import javax.ejb.NoSuchEntityException JavaDoc;
13 import javax.ejb.ObjectNotFoundException JavaDoc;
14 import javax.ejb.RemoveException JavaDoc;
15 import javax.ejb.CreateException JavaDoc;
16 import javax.ejb.DuplicateKeyException JavaDoc;
17 import javax.ejb.EJBException JavaDoc;
18
19 import javax.sql.DataSource JavaDoc;
20 import javax.naming.InitialContext JavaDoc;
21 import javax.naming.NamingException JavaDoc;
22
23 import java.sql.Connection JavaDoc;
24 import java.sql.Statement JavaDoc;
25 import java.sql.ResultSet JavaDoc;
26 import java.sql.SQLException JavaDoc;
27
28 import java.util.Set JavaDoc;
29
30 import org.apache.log4j.Category;
31
32 /**
33  * Models an employee.
34  *
35  * @ejb.bean
36  * name="Employee"
37  * generate="true"
38  * view-type="local"
39  * type="CMP"
40  * local-jndi-name="EmployeeEJB.EmployeeHome"
41  * reentrant="False"
42  * cmp-version="2.x"
43  * primkey-field="name"
44  *
45  * @ejb.pk
46  * class="java.lang.String"
47  * generate="false"
48  *
49  * @ejb.transaction type="Required"
50  *
51  * @@ejb.finder signature="Collection findAll()"
52  *
53  * @@ejb.persistence table-name="employee"
54  * @weblogic:table-name employee
55  *
56  * @jboss.create-table "${jboss.create.table}"
57  * @jboss.remove-table "${jboss.remove.table}"
58  *
59  * @author <a HREF="mailto:loubyansky@ua.fm">Alex Loubyansky</a>
60  */

61 public abstract class EmployeeBean
62    implements EntityBean JavaDoc
63 {
64    // Constants -----------------------------------------------------
65
static Category log = Category.getInstance( EmployeeBean.class );
66
67    // Attributes ----------------------------------------------------
68
private EntityContext JavaDoc ctx;
69
70    // CMP
71

72    /**
73     * Employee's name: primary key field
74     *
75     * @ejb.pk-field
76     * @ejb.persistent-field
77     * @ejb.interface-method
78     *
79     * xdoclet needs to be updated
80     * @@ejb.persistence
81     * column-name="name"
82     * jdbc-type="VARCHAR"
83     * sql-type="VARCHAR(50)"
84     *
85     * @weblogic:dbms-column name
86     */

87    public abstract String JavaDoc getName();
88    public abstract void setName(String JavaDoc name);
89
90
91    // CMR
92

93    /**
94     * Company: bidirectional CMR
95     *
96     * @ejb.interface-method
97     *
98     * @ejb.relation
99     * name="Company-Employee"
100     * role-name="Employee-Has-Company"
101     * cascade-delete="yes"
102     *
103     * @jboss.relation
104     * fk-constraint="false"
105     * related-pk-field="name"
106     * pk-column="company_name"
107     */

108    public abstract CompanyLocal getCompany();
109    /**
110     * @ejb.interface-method
111     */

112    public abstract void setCompany(CompanyLocal company);
113
114    // EntityBean Implementation -------------------------------------
115
/**
116     * @ejb.create-method
117     */

118    public String JavaDoc ejbCreate( String JavaDoc name )
119       throws CreateException JavaDoc
120    {
121       setName(name);
122       return null; // See 9.4.2 of the EJB 1.1 specification
123
}
124
125    public void ejbPostCreate( String JavaDoc name ) { }
126
127    public void ejbRemove()
128       throws RemoveException JavaDoc
129    {
130       log.debug("removed: " + ctx.getPrimaryKey() );
131    }
132
133    public void setEntityContext(EntityContext JavaDoc ctx)
134    {
135       this.ctx = ctx;
136    }
137
138    public void unsetEntityContext()
139    {
140       ctx = null;
141    }
142
143    public void ejbActivate() { }
144    public void ejbPassivate() { }
145    public void ejbLoad() { }
146    public void ejbStore() { }
147 }
148
Popular Tags