001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.cmp2.fkstackoverflow.ejb;
023:
024: import org.apache.log4j.Category;
025:
026: import javax.ejb.EntityBean;
027: import javax.ejb.EntityContext;
028: import javax.ejb.RemoveException;
029: import javax.ejb.CreateException;
030:
031: /**
032: * @ejb.bean
033: * name="Child"
034: * type="CMP"
035: * cmp-version="2.x"
036: * view-type="local"
037: * reentrant="false"
038: * primkey-field="id"
039: * @ejb.pk generate="false"
040: * @ejb.util generate="physical"
041: * @ejb.persistence table-name="CHILD"
042: * @ejb:transaction type="Required"
043: * @ejb:transaction-type type="Container"
044: * @jboss.persistence
045: * create-table="true"
046: * remove-table="true"
047: */
048: public abstract class ChildEntityBean implements EntityBean {
049: Category log = Category.getInstance(ChildEntityBean.class);
050: private EntityContext ctx;
051:
052: // CMP accessors
053:
054: /**
055: * @ejb.pk-field
056: * @ejb.persistent-field
057: * @ejb.interface-method
058: * @ejb.persistence column-name="CHILD_ID"
059: */
060: public abstract Long getId();
061:
062: public abstract void setId(Long id);
063:
064: /**
065: * @ejb.persistent-field
066: * @ejb.interface-method
067: * @ejb.persistence column-name="FIRST_NAME"
068: */
069: public abstract String getFirstName();
070:
071: public abstract void setFirstName(String name);
072:
073: /**
074: * @ejb.persistent-field
075: * @ejb.interface-method
076: * @ejb.persistence column-name="PARENT_ID"
077: */
078: public abstract Long getSimpleParentId();
079:
080: /**
081: * @ejb.interface-method
082: */
083: public abstract void setSimpleParentId(Long parentId);
084:
085: /**
086: * @ejb.persistent-field
087: * @ejb.interface-method
088: * @ejb.persistence column-name="COMPLEXPARENT_ID1"
089: */
090: public abstract Long getComplexParentId1();
091:
092: /**
093: * @ejb.interface-method
094: */
095: public abstract void setComplexParentId1(Long parentId);
096:
097: /**
098: * @ejb.persistent-field
099: * @ejb.interface-method
100: * @ejb.persistence column-name="COMPLEXPARENT_ID2"
101: */
102: public abstract Long getComplexParentId2();
103:
104: /**
105: * @ejb.interface-method
106: */
107: public abstract void setComplexParentId2(Long parentId);
108:
109: // CMR
110:
111: /**
112: * @ejb.interface-method
113: * @ejb.relation
114: * name="parent-children-simple1"
115: * role-name="child-has-parent"
116: * cascade-delete="false"
117: * @jboss.relation
118: * fk-column="PARENT_ID"
119: * related-pk-field="id"
120: */
121: public abstract SimpleParentLocal getSimpleParent1();
122:
123: /**
124: * @ejb.interface-method
125: */
126: public abstract void setSimpleParent1(SimpleParentLocal parent);
127:
128: /**
129: * @ejb.interface-method
130: * @ejb.relation
131: * name="parent-children-simple2"
132: * role-name="child-has-parent"
133: * cascade-delete="false"
134: * @jboss.relation
135: * fk-column="PARENT_ID"
136: * related-pk-field="id"
137: */
138: public abstract SimpleParentLocal getSimpleParent2();
139:
140: /**
141: * @ejb.interface-method
142: */
143: public abstract void setSimpleParent2(SimpleParentLocal parent);
144:
145: /**
146: * @ejb.interface-method
147: * @ejb.relation
148: * name="parent-children-complex1"
149: * role-name="child-has-parent"
150: * cascade-delete="false"
151: * @jboss.relation
152: * fk-column="COMPLEXPARENT_ID1"
153: * related-pk-field="id1"
154: * @jboss.relation
155: * fk-column="COMPLEXPARENT_ID2"
156: * related-pk-field="id2"
157: */
158: public abstract ComplexParentLocal getComplexParent1();
159:
160: /**
161: * @ejb.interface-method
162: */
163: public abstract void setComplexParent1(ComplexParentLocal parent);
164:
165: /**
166: * @ejb.interface-method
167: * @ejb.relation
168: * name="parent-children-complex2"
169: * role-name="child-has-parent"
170: * cascade-delete="false"
171: * @jboss.relation
172: * fk-column="COMPLEXPARENT_ID1"
173: * related-pk-field="id1"
174: * @jboss.relation
175: * fk-column="COMPLEXPARENT_ID2"
176: * related-pk-field="id2"
177: */
178: public abstract ComplexParentLocal getComplexParent2();
179:
180: /**
181: * @ejb.interface-method
182: */
183: public abstract void setComplexParent2(ComplexParentLocal parent);
184:
185: // EntityBean implementation
186:
187: /**
188: * @ejb.create-method
189: * @throws CreateException
190: */
191: public Long ejbCreate(Long childId, String firstName, Long parentId)
192: throws CreateException {
193: setId(childId);
194: setFirstName(firstName);
195: setSimpleParentId(parentId);
196: return null;
197: }
198:
199: public void ejbPostCreate(Long childId, String firstName,
200: Long parentId) {
201: }
202:
203: /**
204: * @param ctx The new entityContext value
205: */
206: public void setEntityContext(EntityContext ctx) {
207: this .ctx = ctx;
208: }
209:
210: /**
211: * Unset the associated entity context.
212: */
213: public void unsetEntityContext() {
214: this .ctx = null;
215: }
216:
217: public void ejbActivate() {
218: }
219:
220: public void ejbLoad() {
221: }
222:
223: public void ejbPassivate() {
224: }
225:
226: public void ejbRemove() throws RemoveException {
227: }
228:
229: public void ejbStore() {
230: }
231: }
|