KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > relation > tier > TierBean


1 package org.objectweb.jonas.jtests.beans.relation.tier;
2
3 import javax.ejb.EJBException JavaDoc;
4
5 public abstract class TierBean
6
7 implements javax.ejb.EntityBean JavaDoc {
8
9     protected javax.ejb.EntityContext JavaDoc entityCtx = null;
10
11     protected TierValue TierValue = null;
12
13     /**
14      * Returns the numinttie
15      * @return the numinttie
16      */

17     public abstract java.lang.Integer JavaDoc getNuminttie();
18
19     /**
20      * Sets the numinttie
21      * @param numinttie the new numinttie value
22      */

23     public abstract void setNuminttie(java.lang.Integer JavaDoc numinttie);
24
25     /**
26      * Returns the emailtie
27      * @return the emailtie
28      */

29     public abstract java.lang.String JavaDoc getEmailtie();
30
31     /**
32      * Sets the emailtie
33      * @param emailtie the new emailtie value
34      */

35     public abstract void setEmailtie(java.lang.String JavaDoc emailtie);
36
37
38     /**
39      * This is a bi-directional one-to-one relationship CMR method
40      * @return the related TiephyLocal.
41      */

42     public abstract TiephyLocal getTiephy();
43
44     /**
45      * get method relation one
46      */

47     public TiephyValue getTiephyValue() {
48         // return the value !
49
return getTiephy().getTiephyValue();
50     }
51
52     /**
53      * get method relation one
54      */

55     public void setTiephyValue(TiephyValue value) {
56         getTiephy().update(value);
57     }
58
59     /**
60      * Sets the related test.entity.tiephy.TiephyLocal
61      */

62     public abstract void setTiephy(TiephyLocal tiephy);
63
64     /**
65      * This is a bi-directional one-to-one relationship CMR method
66      * @return the related TiemorLocal.
67      */

68     public abstract TiemorLocal getTiemor();
69
70     /**
71      * get method relation one
72      */

73     public TiemorValue getTiemorValue() {
74         // return the value !
75
return getTiemor().getTiemorValue();
76     }
77
78     /**
79      * get method relation one
80      */

81     public void setTiemorValue(TiemorValue value) {
82         getTiemor().update(value);
83     }
84
85     /**
86      * Sets the related test.entity.tiemor.TiemorLocal
87      * @param tiemor the related TiemorLocal
88      */

89     public abstract void setTiemor(TiemorLocal tiemor);
90
91     /**
92      * Return the value object version of this entity.
93      */

94     public TierValue getTierValue() {
95         try {
96             TierValue = new TierValue();
97             TierValue = setColumns(TierValue);
98             return TierValue;
99         } catch (EJBException JavaDoc e) {
100             // TODO Auto-generated catch block
101
e.printStackTrace();
102         } catch (IllegalStateException JavaDoc e) {
103             // TODO Auto-generated catch block
104
e.printStackTrace();
105         }
106         return null;
107
108     }
109
110     /**
111      * Update the value object version of this entity.
112      * @ejb.interface-method view-type="local"
113      */

114     public void update(TierValue value) {
115         if (value.emailtieHasBeenSet()) setEmailtie(value.getEmailtie());
116     }
117
118     /**
119      * Creates an instance based on a value object When the client invokes a
120      * create method, the EJB container invokes the ejbCreate method. Typically,
121      * an ejbCreate method in an entity bean performs the following tasks:
122      * <UL>
123      * <LI>Inserts the entity state into the database.</LI>
124      * <LI>Initializes the instance variables.</LI>
125      * <LI>Returns the primary key.</LI>
126      * </UL>
127      * @param value the value object used to initialise the new instance
128      * @return the primary key of the new instance
129      * @ejb.create-method view-type="local"
130      */

131     public java.lang.Integer JavaDoc ejbCreate(TierValue value) throws javax.ejb.CreateException JavaDoc {
132         // Use Middlegen's Sequence Block PK generator. Only works for numeric
133
// fields
134
try {
135             SequenceSessionLocal sequenceGenerator = SequenceSessionUtil.getLocalHome().create();
136             setNuminttie(new java.lang.Integer JavaDoc(Integer.toString(sequenceGenerator
137                     .getNextSequenceNumber("CNEDI.TIERS.NUMINTTIE"))));
138         } catch (javax.naming.NamingException JavaDoc e) {
139             throw new javax.ejb.CreateException JavaDoc(e.getMessage());
140         }
141         // Use XDoclet's GUID generator. Only works for String fields
142
// This requires <utilobject includeGUID="true"/> in ejbdoclet.
143

144         setEmailtie(value.getEmailtie());
145         // EJB 2.0 spec says return null for CMP ejbCreate methods.
146
return null;
147     }
148
149     /**
150      * The container invokes this method immediately after it calls ejbCreate.
151      * @param value the value object used to initialise the new instance
152      */

153     public void ejbPostCreate(TierValue value) throws javax.ejb.CreateException JavaDoc {
154     }
155
156
157     public void setEntityContext(javax.ejb.EntityContext JavaDoc entityCtx) {
158         this.entityCtx = entityCtx;
159     }
160
161     public void unsetEntityContext() {
162         this.entityCtx = null;
163     }
164
165     private TierValue setColumns(TierValue value) {
166         value.setNuminttie(getNuminttie());
167         value.setEmailtie(getEmailtie());
168         return value;
169     }
170 }
Popular Tags