KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > ejb > cmr > LanguageBean


1 package test.ejb.cmr;
2
3 /**
4     * This class is part of Middlegen airlines, and it is a CMP EJB accessing the language table.
5     *
6     * @author <a HREF="http://middlegen.codehaus.org/">Middlegen</a>
7     * @todo generate create methods which don't take pk as arg (and use an arbitrary pk generator internally)
8     * @ejb.bean
9     * cmp-version="2.x"
10     * local-jndi-name="airline.LanguageLocalHome"
11     * name="Language"
12     * primkey-field="languageId"
13     * type="CMP"
14     * view-type="local"
15     * @ejb.finder
16     * method-intf="LocalHome"
17     * query="SELECT OBJECT(o) FROM Language o"
18     * result-type-mapping="Local"
19     * signature="java.util.Collection findAll()"
20     * @ejb.finder
21     * method-intf="LocalHome"
22     * query="SELECT DISTINCT OBJECT(o) FROM Language o WHERE o.languageCode = ?1"
23     * result-type-mapping="Local"
24     * signature="java.util.Collection findByLanguageCode(test.ejb.cmr.LanguageCodeLocal languageCode)"
25     * @ejb.finder
26     * method-intf="LocalHome"
27     * query="SELECT DISTINCT OBJECT(o) FROM Language o WHERE o.name = ?1"
28     * result-type-mapping="Local"
29     * signature="java.util.Collection findByName(java.lang.String name)"
30     * @ejb.persistence
31     * table-name="language"
32     * @weblogic.data-source-name airline.database
33     * @XXweblogic.data-source-name $table.datasourceName
34     * @XXweblogic.resource-description
35     * @orion.bean
36     * data-source="airline.database"
37     */

38 public abstract class LanguageBean implements javax.ejb.EntityBean JavaDoc {
39
40    /**
41     * Context set by container
42     */

43    private javax.ejb.EntityContext JavaDoc _entityContext;
44
45    /**
46     * Returns the languageId
47     *
48     * @todo support OracleClob,OracleBlob on WLS
49     * @return the languageId
50     * @ejb.persistent-field
51     * @ejb.persistence
52     * column-name="language_id"
53     * @ejb.interface-method
54     * view-type="local"
55     * @ejb.pk-field
56     */

57    public abstract java.lang.Integer JavaDoc getLanguageId();
58
59    /**
60     * Sets the languageId
61     *
62     * @param java.lang.Integer the new languageId value
63     */

64    public abstract void setLanguageId(java.lang.Integer JavaDoc languageId);
65
66    /**
67     * Returns the languageCodeIdFk
68     *
69     * @todo support OracleClob,OracleBlob on WLS
70     * @return the languageCodeIdFk
71     * @ejb.persistent-field
72     * @ejb.persistence
73     * column-name="language_code_id_fk"
74     */

75    public abstract java.lang.Integer JavaDoc getLanguageCodeIdFk();
76
77    /**
78     * Sets the languageCodeIdFk
79     *
80     * @param java.lang.Integer the new languageCodeIdFk value
81     */

82    public abstract void setLanguageCodeIdFk(java.lang.Integer JavaDoc languageCodeIdFk);
83
84    /**
85     * Returns the name
86     *
87     * @todo support OracleClob,OracleBlob on WLS
88     * @return the name
89     * @ejb.persistent-field
90     * @ejb.persistence
91     * column-name="name"
92     * @ejb.interface-method
93     * view-type="local"
94     */

95    public abstract java.lang.String JavaDoc getName();
96
97    /**
98     * Sets the name
99     *
100     * @param java.lang.String the new name value
101     * @ejb.interface-method
102     * view-type="local"
103     */

104    public abstract void setName(java.lang.String JavaDoc name);
105
106     /**
107     * Returns the related test.ejb.cmr.LanguageCodeLocal
108     *
109     * @return the related test.ejb.cmr.LanguageCodeLocal
110     * @ejb.interface-method
111     * view-type="local"
112     * @ejb.relation
113     * name="language-language_code"
114     * role-name="language-has-language_code"
115     * cascade-delete="true"
116     * @weblogic.column-map
117     * foreign-key-column="language_code_id_fk"
118     * @jboss.relation
119     * fk-column="language_code_id_fk"
120     * related-pk-field="languageCodeId"
121     * batch-cascade-delete="true"
122     */

123    public abstract test.ejb.cmr.LanguageCodeLocal getLanguageCode();
124
125    /**
126     * Sets the related test.ejb.cmr.LanguageCodeLocal
127     *
128     * @param test.ejb.cmr.LanguageLocal the related languageCode
129     * @ejb.interface-method
130     * view-type="local"
131     * @param languageCode the new CMR value
132     */

133    public abstract void setLanguageCode(test.ejb.cmr.LanguageCodeLocal languageCode);
134
135    /**
136     * Returns a collection of related test.ejb.cmr.CityLocal
137     *
138     * @return a collection of related test.ejb.cmr.CityLocal
139     * @ejb.interface-method
140     * view-type="local"
141     * @ejb.relation
142     * name="city-language"
143     * role-name="language-has-city"
144     * @weblogic.relation
145     * join-table-name="language_city"
146     * @weblogic.column-map
147     * foreign-key-column="language_id_fk"
148     * key-column="language_id"
149     * @jboss.relation
150     * fk-column="city_id_fk"
151     * related-pk-field="cityId"
152     *
153     * PLEASE note that jboss.relation declares the *related* PK
154     * field and the FK column in the *current* mapped table.
155     */

156    public abstract java.util.Collection JavaDoc getCities();
157
158    /**
159     * Sets a collection of related test.ejb.cmr.CityLocal
160     *
161     * @param a collection of related test.ejb.cmr.CityLocal
162     * @ejb.interface-method
163     * view-type="local"
164     * @param cities the new CMR value
165     */

166    public abstract void setCities(java.util.Collection JavaDoc cities);
167
168     /**
169     * This create method takes only mandatory (non-nullable) parameters. The pk columns must be provided. When the client invokes a create method, the EJB container invokes the ejbCreate method. Typically, an ejbCreate method in an entity bean performs the following tasks: <UL> <LI>Inserts the entity state into the database.</LI> <LI>Initializes the instance variables.</LI> <LI>Returns the primary key.</LI> </UL>
170     *
171     * @param languageId the languageId value
172     * @param name the name value
173     * @param languageCode mandatory CMR field
174     * @return the primary key of the new instance
175     * @ejb.create-method
176     */

177    public java.lang.Integer JavaDoc ejbCreate( java.lang.Integer JavaDoc languageId, java.lang.String JavaDoc name, test.ejb.cmr.LanguageCodeLocal languageCode ) throws javax.ejb.CreateException JavaDoc {
178       setLanguageId(languageId);
179       setName(name);
180       // EJB 2.0 spec says return null for CMP ejbCreate methods.
181
return null;
182    }
183
184    /**
185     * The container invokes thos method immediately after it calls ejbCreate.
186     *
187     * @param languageId the languageId value
188     * @param name the name value
189     * @param languageCode mandatory CMR field
190     */

191    public void ejbPostCreate( java.lang.Integer JavaDoc languageId, java.lang.String JavaDoc name, test.ejb.cmr.LanguageCodeLocal languageCode ) throws javax.ejb.CreateException JavaDoc {
192       // Set CMR fields
193
setLanguageCode(languageCode);
194    }
195
196      // Implementation of the javax.ejb.EntityBean interface methods
197

198    /**
199     * The container invokes setEntityContext just once - when it creates the bean instance.
200     *
201     */

202    public void setEntityContext(javax.ejb.EntityContext JavaDoc entityContext) {
203       _entityContext = entityContext;
204    }
205
206    /**
207     * At the end of the life cycle, the container removes the instance from the pool and invokes this method.
208     *
209     */

210    public void unsetEntityContext() {
211       _entityContext = null;
212    }
213
214    /**
215     * The container invokes this method to instruct the instance to synchronize its state by loading it state from the underlying database.
216     *
217     */

218    public void ejbLoad() {
219    }
220
221    /**
222     * The container invokes this method when the instance is taken out of the pool of available instances to become associated with a specific EJB object.
223     *
224     */

225    public void ejbActivate() {
226    }
227
228    /**
229     * The container invokes this method on an instance before the instance becomes disassociated with a specific EJB object.
230     *
231     */

232    public void ejbPassivate() {
233    }
234
235    /**
236     * The container invokes this method before it removes the EJB object that is currently associated with the instance.
237     *
238     */

239    public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
240    }
241
242    /**
243     * The container invokes this method to instruct the instance to synchronize its state by storing it to the underlying database.
244     *
245     */

246    public void ejbStore() {
247    }
248 }
249
Popular Tags