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.fkmapping.ejb;
023:
024: import javax.ejb.EntityContext;
025: import javax.ejb.EntityBean;
026: import javax.ejb.EJBException;
027: import javax.ejb.RemoveException;
028: import javax.ejb.CreateException;
029: import java.rmi.RemoteException;
030: import java.util.Collection;
031:
032: /**
033: * @ejb.bean
034: * name="Group"
035: * type="CMP"
036: * cmp-version="2.x"
037: * view-type="local"
038: * reentrant="false"
039: * local-jndi-name="Group"
040: * @ejb.pk generate="true"
041: * @ejb.util generate="physical"
042: * @ejb.persistence table-name="DEPT_GROUP"
043: * @ejb.finder signature="java.util.Collection findAll()"
044: * query="SELECT OBJECT(g) FROM Group g"
045: * @jboss.persistence
046: * create-table="true"
047: * remove-table="true"
048: *
049: * @author <a href="mailto:alex@jboss.org">Alex Loubyansky</a>
050: */
051: public abstract class GroupEntityBean implements EntityBean {
052: // Attributes ---------------------------------------------------
053: private EntityContext ctx;
054:
055: // CMP accessors
056: /**
057: * @ejb.pk-field
058: * @ejb.persistent-field
059: * @ejb.interface-method
060: * @ejb.persistence column-name="DEPT_CODE"
061: */
062: public abstract String getDepartmentCode();
063:
064: public abstract void setDepartmentCode(String deptCode);
065:
066: /**
067: * @ejb.pk-field
068: * @ejb.persistent-field
069: * @ejb.interface-method
070: * @ejb.persistence column-name="DEPT_CODE2"
071: */
072: public abstract String getDepartmentCode2();
073:
074: public abstract void setDepartmentCode2(String deptCode);
075:
076: /**
077: * @ejb.pk-field
078: * @ejb.persistent-field
079: * @ejb.interface-method
080: * @ejb.persistence column-name="GROUP_NUM"
081: */
082: public abstract long getGroupNumber();
083:
084: public abstract void setGroupNumber(long groupNum);
085:
086: /**
087: * @ejb.persistent-field
088: * @ejb.interface-method
089: * @ejb.persistence column-name="DESCR"
090: */
091: public abstract String getDescription();
092:
093: public abstract void setDescription(String description);
094:
095: // CMR accessors
096: /**
097: * @ejb.interface-method
098: * @ejb.relation
099: * name="Department-Group-CompleteFKToPK"
100: * role-name="Group-has-Department"
101: * @jboss.relation
102: * fk-column="DEPT_CODE"
103: * related-pk-field="departmentCode"
104: * @jboss.relation
105: * fk-column="DEPT_CODE2"
106: * related-pk-field="departmentCode2"
107: */
108: public abstract DepartmentLocal getDepartment();
109:
110: /**
111: * @ejb.interface-method
112: */
113: public abstract void setDepartment(DepartmentLocal department);
114:
115: /**
116: * @ejb.interface-method
117: * @ejb.relation
118: * name="Group-Student-PartialFKToPK"
119: * role-name="Group-has-Students"
120: */
121: public abstract Collection getStudents();
122:
123: /**
124: * @ejb.interface-method
125: */
126: public abstract void setStudents(Collection students);
127:
128: /**
129: * @ejb.interface-method
130: * @ejb.relation
131: * name="Group-Exam-FKToCMP"
132: * role-name="Group-has-Exams"
133: */
134: public abstract Collection getExamenations();
135:
136: /**
137: * @ejb.interface-method
138: */
139: public abstract void setExamenations(Collection students);
140:
141: // EntityBean implementation ------------------------------------
142: /**
143: * @ejb.create-method
144: */
145: public GroupPK ejbCreate(String deptCode, long groupNum,
146: String descr) throws CreateException {
147: setDepartmentCode(deptCode);
148: setDepartmentCode2("X" + deptCode);
149: setGroupNumber(groupNum);
150: setDescription(descr);
151: return null;
152: }
153:
154: public void ejbPostCreate(String deptCode, long groupNum,
155: String descr) {
156: }
157:
158: public void ejbActivate() throws EJBException, RemoteException {
159: }
160:
161: public void ejbLoad() throws EJBException, RemoteException {
162: }
163:
164: public void ejbPassivate() throws EJBException, RemoteException {
165: }
166:
167: public void ejbRemove() throws RemoveException, EJBException,
168: RemoteException {
169: }
170:
171: public void ejbStore() throws EJBException, RemoteException {
172: }
173:
174: public void setEntityContext(EntityContext ctx)
175: throws EJBException, RemoteException {
176: this .ctx = ctx;
177: }
178:
179: public void unsetEntityContext() throws EJBException,
180: RemoteException {
181: this.ctx = null;
182: }
183: }
|