KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > fkmapping > ejb > GroupEntityBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.cmp2.fkmapping.ejb;
23
24 import javax.ejb.EntityContext JavaDoc;
25 import javax.ejb.EntityBean JavaDoc;
26 import javax.ejb.EJBException JavaDoc;
27 import javax.ejb.RemoveException JavaDoc;
28 import javax.ejb.CreateException JavaDoc;
29 import java.rmi.RemoteException JavaDoc;
30 import java.util.Collection JavaDoc;
31
32 /**
33  * @ejb.bean
34  * name="Group"
35  * type="CMP"
36  * cmp-version="2.x"
37  * view-type="local"
38  * reentrant="false"
39  * local-jndi-name="Group"
40  * @ejb.pk generate="true"
41  * @ejb.util generate="physical"
42  * @ejb.persistence table-name="DEPT_GROUP"
43  * @ejb.finder signature="java.util.Collection findAll()"
44  * query="SELECT OBJECT(g) FROM Group g"
45  * @jboss.persistence
46  * create-table="true"
47  * remove-table="true"
48  *
49  * @author <a HREF="mailto:alex@jboss.org">Alex Loubyansky</a>
50  */

51 public abstract class GroupEntityBean
52    implements EntityBean JavaDoc
53 {
54    // Attributes ---------------------------------------------------
55
private EntityContext JavaDoc ctx;
56
57    // CMP accessors
58
/**
59     * @ejb.pk-field
60     * @ejb.persistent-field
61     * @ejb.interface-method
62     * @ejb.persistence column-name="DEPT_CODE"
63     */

64    public abstract String JavaDoc getDepartmentCode();
65    public abstract void setDepartmentCode(String JavaDoc deptCode);
66
67    /**
68     * @ejb.pk-field
69     * @ejb.persistent-field
70     * @ejb.interface-method
71     * @ejb.persistence column-name="DEPT_CODE2"
72     */

73    public abstract String JavaDoc getDepartmentCode2();
74    public abstract void setDepartmentCode2(String JavaDoc deptCode);
75
76    /**
77     * @ejb.pk-field
78     * @ejb.persistent-field
79     * @ejb.interface-method
80     * @ejb.persistence column-name="GROUP_NUM"
81     */

82    public abstract long getGroupNumber();
83    public abstract void setGroupNumber(long groupNum);
84
85    /**
86     * @ejb.persistent-field
87     * @ejb.interface-method
88     * @ejb.persistence column-name="DESCR"
89     */

90    public abstract String JavaDoc getDescription();
91    public abstract void setDescription(String JavaDoc description);
92
93    // CMR accessors
94
/**
95     * @ejb.interface-method
96     * @ejb.relation
97     * name="Department-Group-CompleteFKToPK"
98     * role-name="Group-has-Department"
99     * @jboss.relation
100     * fk-column="DEPT_CODE"
101     * related-pk-field="departmentCode"
102     * @jboss.relation
103     * fk-column="DEPT_CODE2"
104     * related-pk-field="departmentCode2"
105     */

106    public abstract DepartmentLocal getDepartment();
107    /**
108     * @ejb.interface-method
109     */

110    public abstract void setDepartment(DepartmentLocal department);
111
112    /**
113     * @ejb.interface-method
114     * @ejb.relation
115     * name="Group-Student-PartialFKToPK"
116     * role-name="Group-has-Students"
117     */

118    public abstract Collection JavaDoc getStudents();
119    /**
120     * @ejb.interface-method
121     */

122    public abstract void setStudents(Collection JavaDoc students);
123
124    /**
125     * @ejb.interface-method
126     * @ejb.relation
127     * name="Group-Exam-FKToCMP"
128     * role-name="Group-has-Exams"
129     */

130    public abstract Collection JavaDoc getExamenations();
131    /**
132     * @ejb.interface-method
133     */

134    public abstract void setExamenations(Collection JavaDoc students);
135
136    // EntityBean implementation ------------------------------------
137
/**
138     * @ejb.create-method
139     */

140    public GroupPK ejbCreate(String JavaDoc deptCode, long groupNum, String JavaDoc descr)
141       throws CreateException JavaDoc
142    {
143       setDepartmentCode(deptCode);
144       setDepartmentCode2("X"+deptCode);
145       setGroupNumber(groupNum);
146       setDescription(descr);
147       return null;
148    }
149
150    public void ejbPostCreate(String JavaDoc deptCode, long groupNum, String JavaDoc descr) {}
151
152    public void ejbActivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
153    public void ejbLoad() throws EJBException JavaDoc, RemoteException JavaDoc {}
154    public void ejbPassivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
155    public void ejbRemove() throws RemoveException JavaDoc, EJBException JavaDoc, RemoteException JavaDoc {}
156    public void ejbStore() throws EJBException JavaDoc, RemoteException JavaDoc {}
157    public void setEntityContext(EntityContext JavaDoc ctx) throws EJBException JavaDoc, RemoteException JavaDoc
158    {
159       this.ctx = ctx;
160    }
161    public void unsetEntityContext() throws EJBException JavaDoc, RemoteException JavaDoc
162    {
163       this.ctx = null;
164    }
165 }
166
Popular Tags