KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.objectweb.jonas.jtests.beans.relation.tier;
2
3 import javax.ejb.EJBException JavaDoc;
4
5
6 /**
7  *
8  *
9  */

10 public abstract class TiemorBean
11
12
13     implements javax.ejb.EntityBean JavaDoc {
14     
15    protected javax.ejb.EntityContext JavaDoc entityCtx = null;
16    protected TiemorValue TiemorValue = null;
17    
18    /**
19     * Returns the numinttie
20     * @return the numinttie
21     */

22    public abstract java.lang.Integer JavaDoc getNuminttie();
23
24    /**
25     * Sets the numinttie
26     * @param numinttie the new numinttie value
27     */

28    public abstract void setNuminttie(java.lang.Integer JavaDoc numinttie);
29
30    /**
31     * Returns the raisoctie
32     * @return the raisoctie
33     */

34    public abstract java.lang.String JavaDoc getRaisoctie();
35
36    /**
37     * Sets the raisoctie
38     * @param raisoctie the new raisoctie value
39     */

40    public abstract void setRaisoctie(java.lang.String JavaDoc raisoctie);
41
42
43    /**
44     * This is a bi-directional one-to-one relationship CMR method
45     * @return the TierLocal.
46     */

47    public abstract TierLocal getTier();
48
49    /**
50      * get method relation one
51     */

52     public TierValue getTierValue() {
53         // return the value !
54
return getTier().getTierValue();
55     }
56     
57    /**
58      * get method relation one
59     */

60     public void setTierValue(TierValue value) {
61         getTier().update(value);
62     }
63    /**
64     * Sets the related test.entity.tiers.TierLocal
65     * @param tier the related test.entity.tiers.TierLocal
66     *
67     */

68    public abstract void setTier(TierLocal tier);
69   
70
71
72
73
74    /**
75     * Return the value object version of this entity.
76     */

77    public TiemorValue getTiemorValue() {
78         try {
79             TiemorValue = new TiemorValue();
80             TiemorValue = setColumns(TiemorValue);
81             return TiemorValue;
82         } catch (EJBException JavaDoc e) {
83             // TODO Auto-generated catch block
84
e.printStackTrace();
85         } catch (IllegalStateException JavaDoc e) {
86             // TODO Auto-generated catch block
87
e.printStackTrace();
88         }
89         return null;
90
91    }
92    
93    /**
94     * Update the value object version of this entity.
95     */

96    public void update(TiemorValue value) {
97         if (value.raisoctieHasBeenSet())
98           setRaisoctie(value.getRaisoctie());
99    }
100    
101    /**
102     * Creates an instance based on a value object
103     *
104     * When the client invokes a create method, the EJB container invokes the ejbCreate method.
105     * Typically, an ejbCreate method in an entity bean performs the following tasks:
106     * <UL>
107     * <LI>Inserts the entity state into the database.</LI>
108     * <LI>Initializes the instance variables.</LI>
109     * <LI>Returns the primary key.</LI>
110     * </UL>
111     *
112     * @param value the value object used to initialise the new instance
113     * @return the primary key of the new instance
114     *
115     * @ejb.create-method view-type="local"
116     *
117     */

118    public java.lang.Integer JavaDoc ejbCreate(TiemorValue value, TierLocal tier) throws javax.ejb.CreateException JavaDoc {
119       // Use Middlegen's Sequence Block PK generator. Only works for numeric fields
120
try {
121          SequenceSessionLocal sequenceGenerator =
122          SequenceSessionUtil.getLocalHome().create();
123          setNuminttie(new java.lang.Integer JavaDoc(Integer.toString(sequenceGenerator.getNextSequenceNumber( "CNEDI.TIEMOR.NUMINTTIE" ))));
124           } catch( javax.naming.NamingException JavaDoc e ) {
125          throw new javax.ejb.CreateException JavaDoc(e.getMessage());
126       }
127       // Use XDoclet's GUID generator. Only works for String fields
128
// This requires <utilobject includeGUID="true"/> in ejbdoclet.
129

130
131       setRaisoctie(value.getRaisoctie());
132       // EJB 2.0 spec says return null for CMP ejbCreate methods.
133
return null;
134    }
135
136    /**
137     * The container invokes this method immediately after it calls ejbCreate.
138     * @param value the value object used to initialise the new instance
139     */

140    public void ejbPostCreate(TiemorValue value, TierLocal tier) throws javax.ejb.CreateException JavaDoc {
141    // Set CMR fields
142
setTier(tier);
143    }
144
145    public void setEntityContext(javax.ejb.EntityContext JavaDoc entityCtx)
146    {
147       this.entityCtx = entityCtx;
148    }
149
150    public void unsetEntityContext()
151    {
152       this.entityCtx = null;
153    }
154
155    private TiemorValue setColumns(TiemorValue value) {
156       value.setNuminttie(getNuminttie());
157       value.setRaisoctie(getRaisoctie());
158       return value;
159    }
160 }
161
Popular Tags