KickJava   Java API By Example, From Geeks To Geeks.

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


1 package test.ejb.cmr;
2
3 /**
4     * This class is part of Middlegen airlines, and it is a CMP EJB accessing the country 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.CountryLocalHome"
11     * name="Country"
12     * primkey-field="countryId"
13     * type="CMP"
14     * view-type="local"
15     * @ejb.finder
16     * method-intf="LocalHome"
17     * query="SELECT OBJECT(o) FROM Country 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 Country o WHERE o.country = ?1"
23     * result-type-mapping="Local"
24     * signature="java.util.Collection findByCountry(test.ejb.cmr.CountryLocal country)"
25     * @ejb.finder
26     * method-intf="LocalHome"
27     * query="SELECT DISTINCT OBJECT(o) FROM Country o WHERE o.name = ?1"
28     * result-type-mapping="Local"
29     * signature="java.util.Collection findByName(java.lang.String name)"
30     * @ejb.persistence
31     * @weblogic.data-source-name airline.database
32     * @XXweblogic.data-source-name $table.datasourceName
33     * @XXweblogic.resource-description
34     * @orion.bean
35     * data-source="airline.database"
36     *
37     * @ejb:util generate="physical"
38     */

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

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

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

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

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

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

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

105    public abstract void setName(java.lang.String JavaDoc name);
106
107     /**
108     * Returns a collection of related test.ejb.cmr.CityLocal
109     *
110     * @return a collection of related test.ejb.cmr.CityLocal
111     * @ejb.interface-method
112     * view-type="local"
113     * @ejb.relation
114     * name="city-country"
115     * role-name="country-has-city"
116     * target-ejb="City"
117     * target-multiple="no"
118     * target-role-name="city-has-country"
119     * @weblogic.target-column-map
120     * foreign-key-column="country_id_fk"
121     * @jboss:target-relation
122     * related-pk-field="countryId"
123     * fk-column="country_id_fk"
124     */

125    public abstract java.util.Collection JavaDoc getCities();
126
127    /**
128     * Sets a collection of related test.ejb.cmr.CityLocal
129     *
130     * @param a collection of related test.ejb.cmr.CityLocal
131     * @ejb.interface-method
132     * view-type="local"
133     * @param cities the new CMR value
134     */

135    public abstract void setCities(java.util.Collection JavaDoc cities);
136
137    /**
138     * Returns a collection of related test.ejb.cmr.CountryLocal
139     *
140     * @return a collection of related test.ejb.cmr.CountryLocal
141     * @ejb.interface-method
142     * view-type="local"
143     * @ejb.relation
144     * name="country-country"
145     * role-name="country-has-country1"
146     * @weblogic.target-column-map
147     * foreign-key-column="owner_id_fk"
148     * @jboss Unidirectional 1->N relationship unsupported by XDoclet
149     */

150    public abstract java.util.Collection JavaDoc getCountries();
151
152    /**
153     * Sets a collection of related test.ejb.cmr.CountryLocal
154     *
155     * @param a collection of related test.ejb.cmr.CountryLocal
156     * @ejb.interface-method
157     * view-type="local"
158     * @param countries the new CMR value
159     */

160    public abstract void setCountries(java.util.Collection JavaDoc countries);
161
162    /**
163     * Returns the related test.ejb.cmr.CountryLocal
164     *
165     * @return the related test.ejb.cmr.CountryLocal
166     * @ejb.interface-method
167     * view-type="local"
168     * @ejb.relation
169     * name="country-country"
170     * role-name="country-has-country2"
171     * @weblogic.column-map
172     * foreign-key-column="owner_id_fk"
173     * @jboss.relation
174     * fk-column="owner_id_fk"
175     * related-pk-field="countryId"
176     */

177    public abstract test.ejb.cmr.CountryLocal getCountry();
178
179    /**
180     * Sets the related test.ejb.cmr.CountryLocal
181     *
182     * @param test.ejb.cmr.CountryLocal the related country
183     * @ejb.interface-method
184     * view-type="local"
185     * @param country the new CMR value
186     */

187    public abstract void setCountry(test.ejb.cmr.CountryLocal country);
188
189     /**
190     * 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>
191     *
192     * @param countryId the countryId value
193     * @param name the name value
194     * @param country mandatory CMR field
195     * @return the primary key of the new instance
196     * @ejb.create-method
197     */

198    public java.lang.Integer JavaDoc ejbCreate( java.lang.Integer JavaDoc countryId, java.lang.String JavaDoc name, test.ejb.cmr.CountryLocal country ) throws javax.ejb.CreateException JavaDoc {
199       setCountryId(countryId);
200       setName(name);
201       // EJB 2.0 spec says return null for CMP ejbCreate methods.
202
return null;
203    }
204
205    /**
206     * The container invokes thos method immediately after it calls ejbCreate.
207     *
208     * @param countryId the countryId value
209     * @param name the name value
210     * @param country mandatory CMR field
211     */

212    public void ejbPostCreate( java.lang.Integer JavaDoc countryId, java.lang.String JavaDoc name, test.ejb.cmr.CountryLocal country ) throws javax.ejb.CreateException JavaDoc {
213       // Set CMR fields
214
setCountry(country);
215    }
216
217      // Implementation of the javax.ejb.EntityBean interface methods
218

219    /**
220     * The container invokes setEntityContext just once - when it creates the bean instance.
221     *
222     */

223    public void setEntityContext(javax.ejb.EntityContext JavaDoc entityContext) {
224       _entityContext = entityContext;
225    }
226
227    /**
228     * At the end of the life cycle, the container removes the instance from the pool and invokes this method.
229     *
230     */

231    public void unsetEntityContext() {
232       _entityContext = null;
233    }
234
235    /**
236     * The container invokes this method to instruct the instance to synchronize its state by loading it state from the underlying database.
237     *
238     */

239    public void ejbLoad() {
240    }
241
242    /**
243     * 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.
244     *
245     */

246    public void ejbActivate() {
247    }
248
249    /**
250     * The container invokes this method on an instance before the instance becomes disassociated with a specific EJB object.
251     *
252     */

253    public void ejbPassivate() {
254    }
255
256    /**
257     * The container invokes this method before it removes the EJB object that is currently associated with the instance.
258     *
259     */

260    public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
261    }
262
263    /**
264     * The container invokes this method to instruct the instance to synchronize its state by storing it to the underlying database.
265     *
266     */

267    public void ejbStore() {
268    }
269 }
270
Popular Tags