001: package hero.entity;
002:
003: import hero.interfaces.BnUserLocal;
004: import hero.interfaces.BnUserPropertyPK;
005: import hero.interfaces.BnUserPropertyValue;
006: import hero.interfaces.InvalidValueException;
007: import javax.ejb.CreateException;
008: import javax.ejb.EJBException;
009: import javax.ejb.EntityBean;
010: import javax.ejb.EntityContext;
011: import javax.ejb.RemoveException;
012:
013: /**
014: * The Entity bean represents a BnUserProperty
015: *
016: * @author Oriol Montala
017: * @version $Revision: 1.9 $
018: *
019: * @ejb:bean name="BnUserProperty"
020: * display-name="BnUser Entity"
021: * type="CMP"
022: * jndi-name="ejb/hero/BnUserProperty"
023: * local-jndi-name="ejb/hero/BnUserProperty_L"
024: * view-type="both"
025: * cmp-version="2.x"
026: * reentrant="true"
027: *
028: *
029: * @ejb:transaction type="Supports"
030: *
031: *
032: * @ejb.pk generate="true" method-intf="both"
033: *
034: * @jonas.bean
035: * lock-policy="container-read-committed"
036: * @jonas.jdbc-mapping
037: * jndi-name="bonita"
038: * jdbc-table-name="BnUserProperty"
039: *
040: * @jonas.shared false
041: *
042: * @ejb:finder signature="java.util.Collection findAll()"
043: * query="SELECT object(u) FROM BnUserProperty u"
044: * transaction-type="Supports"
045: * @ejb:finder signature="java.util.Collection findByUser(java.lang.String userId)" view-type="local"
046: * query="SELECT OBJECT(p) From BnUserProperty p Where p.bnUser.id = ?1"
047: * transaction-type="Supports"
048: * @ejb:finder signature="java.util.Collection findByTheKey(java.lang.String userId, java.lang.String pkey)" view-type="local"
049: * query="SELECT OBJECT(p) From BnUserProperty p Where p.bnUser.id = ?1 AND p.theKey=?2"
050: * transaction-type="Supports"
051: *
052: *
053: * @ejb.value-object
054: * match="*"
055: * name="BnUserProperty"
056: *
057: * @ejb.value-object
058: * match="light"
059: * name="BnUserPropertyLight"
060: *
061: * @jboss.persistence
062: * table-name="BnUserProperty"
063: * create-table="true"
064: * remove-table="false"
065: *
066: * @jboss.container-configuration name="Standard CMP 2.x EntityBean for Bonita"
067: **/
068: public abstract class BnUserPropertyBean implements EntityBean {
069:
070: // -------------------------------------------------------------------------
071: // Members
072: // -------------------------------------------------------------------------
073:
074: public EntityContext mContext;
075:
076: // -------------------------------------------------------------------------
077: // Methods
078: // -------------------------------------------------------------------------
079:
080: // -------------------------------------------------------------------------
081: // Properties (Getters/Setters)
082: // -------------------------------------------------------------------------
083:
084: /**
085: * Retrieve the BnUserProperty's id.
086: *
087: * @return Returns an int representing the id of this BnUserProperty.
088: *
089: * @ejb:pk-field
090: * @ejb.value-object
091: * match="light"
092: * @ejb:persistence column-name="id"
093: * @jonas.cmp-field-jdbc-mapping
094: * field-name="id"
095: * jdbc-field-name="id"
096: * @ejb:transaction type="Supports"
097: **/
098: public abstract String getId();
099:
100: /**
101: * Set the Property's id.
102: *
103: * @param pId The id of this Property. Is set at creation time.
104: * @ejb:transaction type="Required"
105: **/
106: public abstract void setId(String pId);
107:
108: /** Retrieve the BnUser.
109: *
110: * @return Returns a BnUserLocal.
111: * @ejb:interface-method view-type="both"
112: * @ejb:relation name="userprp" role-name="property-by" cascade-delete="yes"
113: * @ejb:transaction type="Supports"
114: *
115: * @jboss.relation
116: * related-pk-field = "id"
117: * fk-column = "userProperyIdFK"
118: **/
119: public abstract BnUserLocal getBnUser();
120:
121: /**
122: * Set the BnUser.
123: *
124: * @ejb:interface-method view-type="local"
125: * @param pUser The BnUser of this Property.
126: * @ejb:transaction type="Required"
127: **/
128: public abstract void setBnUser(BnUserLocal pUser);
129:
130: /**
131: * Retrieve the Key value.
132: *
133: * @return Returns an String representing the Key value of this Property.
134: *
135: * @ejb:interface-method view-type="both"
136: * @ejb.value-object
137: * match="light"
138: * @ejb:persistence column-name="thekey"
139: * @ejb:transaction type="Supports"
140: **/
141: public abstract String getTheKey();
142:
143: /**
144: * Set the key value.
145: * @ejb:interface-method view-type="both"
146: * @param key The Key of this Property.
147: * @ejb:transaction type="Required"
148: **/
149: public abstract void setTheKey(String key);
150:
151: /**
152: * Retrieve the Value value.
153: *
154: * @return Returns an String representing the Value value of this Property.
155: *
156: * @ejb:interface-method view-type="both"
157: * @ejb.value-object
158: * match="light"
159: * @ejb:persistence column-name="thevalue"
160: * @ejb:transaction type="Supports"
161: **/
162: public abstract String getTheValue();
163:
164: /**
165: * Set the Value value.
166: * @ejb:interface-method view-type="both"
167: * @param value The Value value of this Property.
168: * @ejb:transaction type="Required"
169: **/
170: public abstract void setTheValue(String value);
171:
172: /**
173: * @ejb.interface-method
174: * @ejb:transaction type="Supports"
175: */
176: public abstract BnUserPropertyValue getBnUserPropertyValue();
177:
178: /**
179: * @ejb.interface-method
180: */
181: public abstract void setBnUserPropertyValue(BnUserPropertyValue v);
182:
183: // -------------------------------------------------------------------------
184: // Framework Callbacks
185: // -------------------------------------------------------------------------
186:
187: /**
188: * Create a Property based on the supplied Property Value Object.
189: *
190: *
191: * @throws InvalidValueException If one of the values are not correct,
192: * this will not roll back the transaction
193: * because the caller has the chance to
194: * fix the problem and try again
195: * @throws EJBException If no new unique ID could be retrieved this will
196: * rollback the transaction because there is no
197: * hope to try again
198: * @throws CreateException Because we have to do so (EJB spec.)
199: *
200: * @ejb:create-method view-type="both"
201: **/
202: public BnUserPropertyPK ejbCreate(BnUserPropertyValue prp)
203: throws InvalidValueException, EJBException, CreateException {
204: this .setId(hero.interfaces.BnUserPropertyUtil
205: .generateGUID(this ));
206: // This is only possible in CMPs. Otherwise return a valid PK.
207: return null;
208: }
209:
210: public void ejbPostCreate(BnUserPropertyValue prp) {
211: // Assign value object in ejbPostCreate to apply XDoclet best
212: // practice. If not done, there will be an error in JBoss if
213: // the Value Object has relations.
214: this .setBnUserPropertyValue(prp);
215: }
216:
217: /**
218: * Create a Property based on the supplied key and value.
219: *
220: *
221: * @throws InvalidValueException If one of the values are not correct,
222: * this will not roll back the transaction
223: * because the caller has the chance to
224: * fix the problem and try again
225: * @throws EJBException If no new unique ID could be retrieved this will
226: * rollback the transaction because there is no
227: * hope to try again
228: * @throws CreateException Because we have to do so (EJB spec.)
229: *
230: * @ejb:create-method view-type="both"
231: **/
232: public BnUserPropertyPK ejbCreate(String key, String value)
233: throws InvalidValueException, EJBException, CreateException {
234: this .setTheKey(key);
235: this .setTheValue(value);
236: this .setId(hero.interfaces.BnUserPropertyUtil
237: .generateGUID(this ));
238:
239: // This is only possible in CMPs. Otherwise return a valid PK.
240: return null;
241: }
242:
243: public void setEntityContext(EntityContext lContext) {
244: mContext = lContext;
245: }
246:
247: public void unsetEntityContext() {
248: mContext = null;
249: }
250:
251: public void ejbActivate() {
252: }
253:
254: public void ejbPassivate() {
255: }
256:
257: public void ejbLoad() {
258: }
259:
260: public void ejbStore() {
261: }
262:
263: public void ejbRemove() throws RemoveException {
264: }
265:
266: }
|