KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > fkstackoverflow > ejb > ChildEntityBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.cmp2.fkstackoverflow.ejb;
23
24 import org.jboss.logging.Logger;
25
26 import javax.ejb.EntityBean JavaDoc;
27 import javax.ejb.EntityContext JavaDoc;
28 import javax.ejb.RemoveException JavaDoc;
29 import javax.ejb.CreateException JavaDoc;
30
31
32 /**
33  * @ejb.bean
34  * name="Child"
35  * type="CMP"
36  * cmp-version="2.x"
37  * view-type="local"
38  * reentrant="false"
39  * primkey-field="id"
40  * @ejb.pk generate="false"
41  * @ejb.util generate="physical"
42  * @ejb.persistence table-name="CHILD"
43  * @ejb:transaction type="Required"
44  * @ejb:transaction-type type="Container"
45  * @jboss.persistence
46  * create-table="true"
47  * remove-table="true"
48  */

49 public abstract class ChildEntityBean
50    implements EntityBean JavaDoc
51 {
52    Logger log = Logger.getLogger(ChildEntityBean.class);
53    private EntityContext JavaDoc ctx;
54
55    // CMP accessors
56

57    /**
58     * @ejb.pk-field
59     * @ejb.persistent-field
60     * @ejb.interface-method
61     * @ejb.persistence column-name="CHILD_ID"
62     */

63    public abstract Long JavaDoc getId();
64    public abstract void setId(Long JavaDoc id);
65
66    /**
67     * @ejb.persistent-field
68     * @ejb.interface-method
69     * @ejb.persistence column-name="FIRST_NAME"
70     */

71    public abstract String JavaDoc getFirstName();
72    public abstract void setFirstName(String JavaDoc name);
73
74    /**
75     * @ejb.persistent-field
76     * @ejb.interface-method
77     * @ejb.persistence column-name="PARENT_ID"
78     */

79    public abstract Long JavaDoc getSimpleParentId();
80    /**
81     * @ejb.interface-method
82     */

83    public abstract void setSimpleParentId(Long JavaDoc parentId);
84
85    /**
86     * @ejb.persistent-field
87     * @ejb.interface-method
88     * @ejb.persistence column-name="COMPLEXPARENT_ID1"
89     */

90    public abstract Long JavaDoc getComplexParentId1();
91    /**
92     * @ejb.interface-method
93     */

94    public abstract void setComplexParentId1(Long JavaDoc parentId);
95
96    /**
97     * @ejb.persistent-field
98     * @ejb.interface-method
99     * @ejb.persistence column-name="COMPLEXPARENT_ID2"
100     */

101    public abstract Long JavaDoc getComplexParentId2();
102    /**
103     * @ejb.interface-method
104     */

105    public abstract void setComplexParentId2(Long JavaDoc parentId);
106
107    // CMR
108

109    /**
110     * @ejb.interface-method
111     * @ejb.relation
112     * name="parent-children-simple1"
113     * role-name="child-has-parent"
114     * cascade-delete="false"
115     * @jboss.relation
116     * fk-column="PARENT_ID"
117     * related-pk-field="id"
118     */

119    public abstract SimpleParentLocal getSimpleParent1();
120    /**
121     * @ejb.interface-method
122     */

123    public abstract void setSimpleParent1(SimpleParentLocal parent);
124
125    /**
126     * @ejb.interface-method
127     * @ejb.relation
128     * name="parent-children-simple2"
129     * role-name="child-has-parent"
130     * cascade-delete="false"
131     * @jboss.relation
132     * fk-column="PARENT_ID"
133     * related-pk-field="id"
134     */

135    public abstract SimpleParentLocal getSimpleParent2();
136    /**
137     * @ejb.interface-method
138     */

139    public abstract void setSimpleParent2(SimpleParentLocal parent);
140
141    /**
142     * @ejb.interface-method
143     * @ejb.relation
144     * name="parent-children-complex1"
145     * role-name="child-has-parent"
146     * cascade-delete="false"
147     * @jboss.relation
148     * fk-column="COMPLEXPARENT_ID1"
149     * related-pk-field="id1"
150     * @jboss.relation
151     * fk-column="COMPLEXPARENT_ID2"
152     * related-pk-field="id2"
153     */

154    public abstract ComplexParentLocal getComplexParent1();
155    /**
156     * @ejb.interface-method
157     */

158    public abstract void setComplexParent1(ComplexParentLocal parent);
159
160    /**
161     * @ejb.interface-method
162     * @ejb.relation
163     * name="parent-children-complex2"
164     * role-name="child-has-parent"
165     * cascade-delete="false"
166     * @jboss.relation
167     * fk-column="COMPLEXPARENT_ID1"
168     * related-pk-field="id1"
169     * @jboss.relation
170     * fk-column="COMPLEXPARENT_ID2"
171     * related-pk-field="id2"
172     */

173    public abstract ComplexParentLocal getComplexParent2();
174    /**
175     * @ejb.interface-method
176     */

177    public abstract void setComplexParent2(ComplexParentLocal parent);
178
179    // EntityBean implementation
180

181    /**
182     * @ejb.create-method
183     * @throws CreateException
184     */

185    public Long JavaDoc ejbCreate(Long JavaDoc childId, String JavaDoc firstName, Long JavaDoc parentId)
186       throws CreateException JavaDoc
187    {
188       setId(childId);
189       setFirstName(firstName);
190       setSimpleParentId(parentId);
191       return null;
192    }
193
194    public void ejbPostCreate(Long JavaDoc childId, String JavaDoc firstName, Long JavaDoc parentId)
195    {
196    }
197
198    /**
199     * @param ctx The new entityContext value
200     */

201    public void setEntityContext(EntityContext JavaDoc ctx)
202    {
203       this.ctx = ctx;
204    }
205
206    /**
207     * Unset the associated entity context.
208     */

209    public void unsetEntityContext()
210    {
211       this.ctx = null;
212    }
213
214    public void ejbActivate() {}
215    public void ejbLoad() {}
216    public void ejbPassivate() {}
217    public void ejbRemove() throws RemoveException JavaDoc {}
218    public void ejbStore() {}
219 }
220
Popular Tags