001: package org.objectweb.jonas.jtests.beans.relation.tier;
002:
003: import javax.ejb.EJBException;
004:
005: /**
006: *
007: *
008: */
009: public abstract class TiemorBean
010:
011: implements javax.ejb.EntityBean {
012:
013: protected javax.ejb.EntityContext entityCtx = null;
014: protected TiemorValue TiemorValue = null;
015:
016: /**
017: * Returns the numinttie
018: * @return the numinttie
019: */
020: public abstract java.lang.Integer getNuminttie();
021:
022: /**
023: * Sets the numinttie
024: * @param numinttie the new numinttie value
025: */
026: public abstract void setNuminttie(java.lang.Integer numinttie);
027:
028: /**
029: * Returns the raisoctie
030: * @return the raisoctie
031: */
032: public abstract java.lang.String getRaisoctie();
033:
034: /**
035: * Sets the raisoctie
036: * @param raisoctie the new raisoctie value
037: */
038: public abstract void setRaisoctie(java.lang.String raisoctie);
039:
040: /**
041: * This is a bi-directional one-to-one relationship CMR method
042: * @return the TierLocal.
043: */
044: public abstract TierLocal getTier();
045:
046: /**
047: * get method relation one
048: */
049: public TierValue getTierValue() {
050: // return the value !
051: return getTier().getTierValue();
052: }
053:
054: /**
055: * get method relation one
056: */
057: public void setTierValue(TierValue value) {
058: getTier().update(value);
059: }
060:
061: /**
062: * Sets the related test.entity.tiers.TierLocal
063: * @param tier the related test.entity.tiers.TierLocal
064: *
065: */
066: public abstract void setTier(TierLocal tier);
067:
068: /**
069: * Return the value object version of this entity.
070: */
071: public TiemorValue getTiemorValue() {
072: try {
073: TiemorValue = new TiemorValue();
074: TiemorValue = setColumns(TiemorValue);
075: return TiemorValue;
076: } catch (EJBException e) {
077: // TODO Auto-generated catch block
078: e.printStackTrace();
079: } catch (IllegalStateException e) {
080: // TODO Auto-generated catch block
081: e.printStackTrace();
082: }
083: return null;
084:
085: }
086:
087: /**
088: * Update the value object version of this entity.
089: */
090: public void update(TiemorValue value) {
091: if (value.raisoctieHasBeenSet())
092: setRaisoctie(value.getRaisoctie());
093: }
094:
095: /**
096: * Creates an instance based on a value object
097: *
098: * When the client invokes a create method, the EJB container invokes the ejbCreate method.
099: * Typically, an ejbCreate method in an entity bean performs the following tasks:
100: * <UL>
101: * <LI>Inserts the entity state into the database.</LI>
102: * <LI>Initializes the instance variables.</LI>
103: * <LI>Returns the primary key.</LI>
104: * </UL>
105: *
106: * @param value the value object used to initialise the new instance
107: * @return the primary key of the new instance
108: *
109: * @ejb.create-method view-type="local"
110: *
111: */
112: public java.lang.Integer ejbCreate(TiemorValue value, TierLocal tier)
113: throws javax.ejb.CreateException {
114: // Use Middlegen's Sequence Block PK generator. Only works for numeric fields
115: try {
116: SequenceSessionLocal sequenceGenerator = SequenceSessionUtil
117: .getLocalHome().create();
118: setNuminttie(new java.lang.Integer(
119: Integer
120: .toString(sequenceGenerator
121: .getNextSequenceNumber("CNEDI.TIEMOR.NUMINTTIE"))));
122: } catch (javax.naming.NamingException e) {
123: throw new javax.ejb.CreateException(e.getMessage());
124: }
125: // Use XDoclet's GUID generator. Only works for String fields
126: // This requires <utilobject includeGUID="true"/> in ejbdoclet.
127:
128: setRaisoctie(value.getRaisoctie());
129: // EJB 2.0 spec says return null for CMP ejbCreate methods.
130: return null;
131: }
132:
133: /**
134: * The container invokes this method immediately after it calls ejbCreate.
135: * @param value the value object used to initialise the new instance
136: */
137: public void ejbPostCreate(TiemorValue value, TierLocal tier)
138: throws javax.ejb.CreateException {
139: // Set CMR fields
140: setTier(tier);
141: }
142:
143: public void setEntityContext(javax.ejb.EntityContext entityCtx) {
144: this .entityCtx = entityCtx;
145: }
146:
147: public void unsetEntityContext() {
148: this .entityCtx = null;
149: }
150:
151: private TiemorValue setColumns(TiemorValue value) {
152: value.setNuminttie(getNuminttie());
153: value.setRaisoctie(getRaisoctie());
154: return value;
155: }
156: }
|