KickJava   Java API By Example, From Geeks To Geeks.

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


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

33 public abstract class CityBean implements javax.ejb.EntityBean JavaDoc {
34
35    /**
36     * Context set by container
37     */

38    private javax.ejb.EntityContext JavaDoc _entityContext;
39
40    /**
41     * Returns the cityId
42     *
43     * @todo support OracleClob,OracleBlob on WLS
44     * @return the cityId
45     * @ejb.persistent-field
46     * @ejb.persistence
47     * column-name="city_id"
48     * @ejb.interface-method
49     * view-type="local"
50     * @ejb.pk-field
51     */

52    public abstract java.lang.Integer JavaDoc getCityId();
53
54    /**
55     * Sets the cityId
56     *
57     * @param java.lang.Integer the new cityId value
58     */

59    public abstract void setCityId(java.lang.Integer JavaDoc cityId);
60
61    /**
62     * Returns the countryIdFk
63     *
64     * @todo support OracleClob,OracleBlob on WLS
65     * @return the countryIdFk
66     * @ejb.persistent-field
67     * @ejb.persistence
68     * column-name="country_id_fk"
69     */

70    public abstract java.lang.Integer JavaDoc getCountryIdFk();
71
72    /**
73     * Sets the countryIdFk
74     *
75     * @param java.lang.Integer the new countryIdFk value
76     */

77    public abstract void setCountryIdFk(java.lang.Integer JavaDoc countryIdFk);
78
79    /**
80     * Returns the name
81     *
82     * @todo support OracleClob,OracleBlob on WLS
83     * @return the name
84     * @ejb.persistent-field
85     * @ejb.persistence
86     * column-name="name"
87     * @ejb.interface-method
88     * view-type="local"
89     */

90    public abstract java.lang.String JavaDoc getName();
91
92    /**
93     * Sets the name
94     *
95     * @param java.lang.String the new name value
96     * @ejb.interface-method
97     * view-type="local"
98     */

99    public abstract void setName(java.lang.String JavaDoc name);
100
101     /**
102     * Returns a collection of related test.ejb.cmr.LanguageLocal
103     *
104     * @return a collection of related test.ejb.cmr.LanguageLocal
105     * @ejb.interface-method
106     * view-type="local"
107     * @ejb.relation
108     * name="city-language"
109     * role-name="city-has-language"
110     * @weblogic.relation
111     * join-table-name="language_city"
112     * @weblogic.column-map
113     * foreign-key-column="city_id_fk"
114     * key-column="city_id"
115     * @jboss.relation
116     * fk-column="language_id_fk"
117     * related-pk-field="languageId"
118     */

119    public abstract java.util.Collection JavaDoc getLanguages();
120
121    /**
122     * Sets a collection of related test.ejb.cmr.LanguageLocal
123     *
124     * @param a collection of related test.ejb.cmr.LanguageLocal
125     * @ejb.interface-method
126     * view-type="local"
127     * @param languages the new CMR value
128     */

129    public abstract void setLanguages(java.util.Collection JavaDoc languages);
130
131     /**
132     * 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>
133     *
134     * @param cityId the cityId value
135     * @param name the name value
136     * @return the primary key of the new instance
137     * @ejb.create-method
138     */

139    public java.lang.Integer JavaDoc ejbCreate( java.lang.Integer JavaDoc cityId, java.lang.String JavaDoc name ) throws javax.ejb.CreateException JavaDoc {
140       setCityId(cityId);
141       setName(name);
142       // EJB 2.0 spec says return null for CMP ejbCreate methods.
143
return null;
144    }
145
146    /**
147     * The container invokes thos method immediately after it calls ejbCreate.
148     *
149     * @param cityId the cityId value
150     * @param name the name value
151     */

152    public void ejbPostCreate( java.lang.Integer JavaDoc cityId, java.lang.String JavaDoc name ) throws javax.ejb.CreateException JavaDoc {
153       // Set CMR fields
154
}
155
156      // Implementation of the javax.ejb.EntityBean interface methods
157

158    /**
159     * The container invokes setEntityContext just once - when it creates the bean instance.
160     *
161     */

162    public void setEntityContext(javax.ejb.EntityContext JavaDoc entityContext) {
163       _entityContext = entityContext;
164    }
165
166    /**
167     * At the end of the life cycle, the container removes the instance from the pool and invokes this method.
168     *
169     */

170    public void unsetEntityContext() {
171       _entityContext = null;
172    }
173
174    /**
175     * The container invokes this method to instruct the instance to synchronize its state by loading it state from the underlying database.
176     *
177     */

178    public void ejbLoad() {
179    }
180
181    /**
182     * 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.
183     *
184     */

185    public void ejbActivate() {
186    }
187
188    /**
189     * The container invokes this method on an instance before the instance becomes disassociated with a specific EJB object.
190     *
191     */

192    public void ejbPassivate() {
193    }
194
195    /**
196     * The container invokes this method before it removes the EJB object that is currently associated with the instance.
197     *
198     */

199    public void ejbRemove() throws javax.ejb.RemoveException JavaDoc {
200    }
201
202    /**
203     * The container invokes this method to instruct the instance to synchronize its state by storing it to the underlying database.
204     *
205     */

206    public void ejbStore() {
207    }
208 }
209
Popular Tags