KickJava   Java API By Example, From Geeks To Geeks.

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


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 a company.
34  *
35  * @ejb.bean
36  * name="Company"
37  * generate="true"
38  * view-type="local"
39  * type="CMP"
40  * local-jndi-name="CompanyEJB.CompanyHome"
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.finder signature="Collection findAll()"
50  *
51  * @ejb.transaction type="Required"
52  *
53  * @@ejb.persistence table-name="company"
54  * @weblogic:table-name company
55  *
56  * @jboss.create-table "${jboss.create.table}"
57  * @jboss.remove-table "${jboss.remove.table}"
58  *
59  * @author <a HREF="mailto:loubyansky@hotmail.com">Alex Loubyansky</a>
60  */

61 public abstract class CompanyBean
62    implements EntityBean JavaDoc
63 {
64    // Constants -----------------------------------------------------
65
static Category log = Category.getInstance( CompanyBean.class );
66
67    // Attributes ----------------------------------------------------
68
private EntityContext JavaDoc ctx;
69
70    // CMP
71
/**
72     * Company's name: primary key field
73     *
74     * @ejb.pk-field
75     * @ejb.persistent-field
76     * @ejb.interface-method
77     *
78     * xdoclet needs to be updated
79     * @@ejb.persistence
80     * column-name="name"
81     * jdbc-type="VARCHAR"
82     * sql-type="VARCHAR(50)"
83     *
84     * @weblogic:dbms-column name
85     */

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

92    /**
93     * Employees: bidirectional CMR
94     *
95     * @ejb.relation
96     * name="Company-Employee"
97     * role-name="Company-Has-Employees"
98     * @ejb.interface-method
99     *
100     * @weblogic.column-map
101     * foreign-key-column="company_name"
102     * key-column="name"
103     */

104    public abstract Set JavaDoc getEmployees();
105    /**
106     * @ejb.interface-method
107     */

108    public abstract void setEmployees(Set JavaDoc employees);
109
110    // EntityBean Implementation -------------------------------------
111
/**
112     * @ejb.create-method
113     */

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