001: /**
002: *
003: * Bonita
004: * Copyright (C) 1999 Bull S.A.
005: * Bull 68 route de versailles 78434 Louveciennes Cedex France
006: * Further information: bonita@objectweb.org
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: *
024: --------------------------------------------------------------------------
025: * $Id: BnRoleMapperBean.java,v 1.12 2006/08/21 09:56:41 brice Exp $
026: *
027: --------------------------------------------------------------------------
028: */package hero.entity;
029:
030: import hero.interfaces.BnRoleMapperPK;
031: import hero.interfaces.BnRoleMapperValue;
032: import hero.interfaces.BnRoleLocal;
033: import hero.interfaces.InvalidValueException;
034:
035: import javax.ejb.CreateException;
036: import javax.ejb.EJBException;
037: import javax.ejb.EntityBean;
038: import javax.ejb.EntityContext;
039: import javax.ejb.RemoveException;
040:
041: /**
042: * The Entity bean represents a BnRoleMapper
043: *
044: * @author Marc Blachon
045: * @version $Revision: 1.12 $
046: *
047: * @ejb:bean name="BnRoleMapper"
048: * display-name="BnRole Mapper Entity"
049: * type="CMP"
050: * jndi-name="ejb/hero/BnRoleMapper"
051: * local-jndi-name="ejb/hero/BnRoleMapper_L"
052: * view-type="both"
053: * cmp-version="2.x"
054: * reentrant="true"
055: *
056: * @ejb:transaction type="Supports"
057: *
058: *
059: * @ejb.pk generate="true" method-intf="both"
060: *
061: * @jonas.bean
062: * lock-policy="container-read-committed"
063: * @jonas.jdbc-mapping
064: * jndi-name="bonita"
065: * jdbc-table-name="BnRoleMapper"
066: *
067: * @jonas.shared false
068: *
069: * @ejb:finder signature="java.util.Collection findAll()"
070: * query="SELECT object(n) FROM BnRoleMapper n"
071: * transaction-type="Supports"
072: *
073: * @ejb:finder signature="java.util.Collection findByRole(java.lang.String RoleId)" view-type="local"
074: * query="SELECT OBJECT(p) From BnRoleMapper p Where p.bnRole.id = ?1"
075: * transaction-type="Supports"
076: *
077: * @ejb:finder signature="hero.interfaces.BnRoleMapperLocal findByName(java.lang.String name)" view-type="local"
078: * query="SELECT OBJECT(p) From BnRoleMapper p Where p.name = ?1"
079: * transaction-type="Supports"
080: *
081: *
082: * @ejb.value-object
083: * match="*"
084: * name="BnRoleMapper"
085: *
086: * @jboss.persistence
087: * table-name="BnRoleMapper"
088: * create-table="true"
089: * remove-table="false"
090: *
091: * @jboss.container-configuration name="Standard CMP 2.x EntityBean for Bonita"
092: **/
093: public abstract class BnRoleMapperBean implements EntityBean {
094:
095: // -------------------------------------------------------------------------
096: // Members
097: // -------------------------------------------------------------------------
098:
099: public EntityContext mContext;
100:
101: // -------------------------------------------------------------------------
102: // Methods
103: // -------------------------------------------------------------------------
104:
105: // -------------------------------------------------------------------------
106: // Properties (Getters/Setters)
107: // -------------------------------------------------------------------------
108:
109: /**
110: * Retrieve the BnRoleMapper's id.
111: *
112: * @return Returns an int representing the id of this BnRoleMapper.
113: *
114: * @ejb:pk-field
115: *
116: * @ejb:persistence column-name="id"
117: * @jonas.cmp-field-jdbc-mapping
118: * field-name="id"
119: * jdbc-field-name="id"
120: * @ejb:transaction type="Supports"
121: **/
122: public abstract String getId();
123:
124: /**
125: * Set the Mapper's id.
126: *
127: * @param pId The id of this Mapper. Is set at creation time.
128: * @ejb:transaction type="Required"
129: **/
130: public abstract void setId(String pId);
131:
132: /** Retrieve the role associated with the mapper.
133: *
134: * @return Returns a String representing the Name of the role.
135: * @ejb:interface-method view-type="both"
136: * @ejb:relation name="mapper-role" role-name="mapper2role" target-ejb="BnRole" cascade-delete="yes"
137: * @ejb:transaction type="Supports"
138: *
139: * @jonas.field-mapping
140: * foreign-key-jdbc-name="fk_role"
141: * key-jdbc-name="id"
142: *
143: * @jboss.relation
144: * related-pk-field = "id"
145: * fk-column = "roleMapperIdFK"
146: **/
147: public abstract BnRoleLocal getBnRole();
148:
149: /**
150: * Set the BnRole.
151: *
152: * @ejb:interface-method view-type="local"
153: * @param pRole The BnRole of this Mapper.
154: * @ejb:transaction type="Required"
155: **/
156: public abstract void setBnRole(BnRoleLocal pRole);
157:
158: /**
159: * Retrieve the Name value.
160: *
161: * @return Returns an String representing the Mapper Name value.
162: *
163: * @ejb:interface-method view-type="both"
164: *
165: * @ejb:persistence column-name="name"
166: * @ejb:transaction type="Supports"
167: **/
168: public abstract String getName();
169:
170: /**
171: * Set the Name value.
172: * @ejb:interface-method view-type="both"
173: * @param key The Name of this Mapper.
174: * @ejb:transaction type="Required"
175: **/
176: public abstract void setName(String mapperName);
177:
178: /**
179: * Retrieve the Type value.
180: *
181: * @return Returns an int representing the Type value.
182: *
183: * @ejb:interface-method view-type="both"
184: *
185: * @ejb:persistence column-name="type"
186: * @ejb:transaction type="Supports"
187: **/
188: public abstract int getType();
189:
190: /**
191: * Set the Type value.
192: * @ejb:interface-method view-type="both"
193: * @param value The Type value of this Mapper.
194: * @ejb:transaction type="Required"
195: **/
196: public abstract void setType(int mapperType);
197:
198: /**
199: * @ejb.interface-method
200: * @ejb:transaction type="Supports"
201: */
202: public abstract BnRoleMapperValue getBnRoleMapperValue();
203:
204: /**
205: * @ejb.interface-method
206: * @ejb:transaction type="Required"
207: */
208: public abstract void setBnRoleMapperValue(BnRoleMapperValue v);
209:
210: // -------------------------------------------------------------------------
211: // Framework Callbacks
212: // -------------------------------------------------------------------------
213:
214: /**
215: * Create a Mapper based on the supplied Mapper Value Object.
216: *
217: *
218: * @throws InvalidValueException If one of the values are not correct,
219: * this will not roll back the transaction
220: * because the caller has the chance to
221: * fix the problem and try again
222: * @throws EJBException If no new unique ID could be retrieved this will
223: * rollback the transaction because there is no
224: * hope to try again
225: * @throws CreateException Because we have to do so (EJB spec.)
226: *
227: * @ejb:create-method view-type="both"
228: **/
229: public BnRoleMapperPK ejbCreate(BnRoleMapperValue prp)
230: throws InvalidValueException, EJBException, CreateException {
231: this .setId(hero.interfaces.BnRoleMapperUtil.generateGUID(this ));
232: // This is only possible in CMPs. Otherwise return a valid PK.
233: return null;
234: }
235:
236: public void ejbPostCreate(BnRoleMapperValue prp) {
237: // Assign value object in ejbPostCreate to apply XDoclet best
238: // practice. If not done, there will be an error in JBoss if
239: // the Value Object has relations.
240: this .setBnRoleMapperValue(prp);
241: }
242:
243: /**
244: * Create a Mapper based on the supplied parameters.
245: *
246: *
247: * @throws InvalidValueException If one of the values are not correct,
248: * this will not roll back the transaction
249: * because the caller has the chance to
250: * fix the problem and try again
251: * @throws EJBException If no new unique ID could be retrieved this will
252: * rollback the transaction because there is no
253: * hope to try again
254: * @throws CreateException Because we have to do so (EJB spec.)
255: *
256: * @ejb:create-method view-type="both"
257: **/
258: public BnRoleMapperPK ejbCreate(String mapperName, int mapperType)
259: throws InvalidValueException, EJBException, CreateException {
260: this .setName(mapperName);
261: this .setType(mapperType);
262: this .setId(hero.interfaces.BnRoleMapperUtil.generateGUID(this ));
263: // This is only possible in CMPs. Otherwise return a valid PK.
264: return null;
265: }
266:
267: public void setEntityContext(EntityContext lContext) {
268: mContext = lContext;
269: }
270:
271: public void unsetEntityContext() {
272: mContext = null;
273: }
274:
275: public void ejbActivate() {
276: }
277:
278: public void ejbPassivate() {
279: }
280:
281: public void ejbLoad() {
282: }
283:
284: public void ejbStore() {
285: }
286:
287: public void ejbRemove() throws RemoveException {
288: }
289: }
|