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="Department"
035: * type="CMP"
036: * cmp-version="2.x"
037: * view-type="local"
038: * reentrant="false"
039: * local-jndi-name="Department"
040: * @ejb.pk generate="true"
041: * @ejb.util generate="physical"
042: * @ejb.persistence table-name="DEPARTMENT"
043: * @jboss.persistence
044: * create-table="true"
045: * remove-table="true"
046: *
047: * @author <a href="mailto:alex@jboss.org">Alex Loubyansky</a>
048: */
049: public abstract class DepartmentEntityBean implements EntityBean {
050: // Attributes ---------------------------------------------------
051: private EntityContext ctx;
052:
053: // CMP accessors
054: /**
055: * @ejb.pk-field
056: * @ejb.persistent-field
057: * @ejb.interface-method
058: * @ejb.persistence column-name="DEPT_CODE"
059: */
060: public abstract String getDepartmentCode();
061:
062: public abstract void setDepartmentCode(String deptCode);
063:
064: /**
065: * @ejb.pk-field
066: * @ejb.persistent-field
067: * @ejb.interface-method
068: * @ejb.persistence column-name="DEPT_CODE2"
069: */
070: public abstract String getDepartmentCode2();
071:
072: public abstract void setDepartmentCode2(String deptCode);
073:
074: /**
075: * @ejb.persistent-field
076: * @ejb.interface-method
077: * @ejb.persistence column-name="DESCR"
078: */
079: public abstract String getDescription();
080:
081: public abstract void setDescription(String description);
082:
083: // CMR accessors
084: /**
085: * @ejb.interface-method
086: * @ejb.relation
087: * name="Institute-Department-StandaloneFK"
088: * role-name="Department-has-Institute"
089: * @jboss.relation
090: * fk-column="INST_ID_FK"
091: * related-pk-field="instituteId"
092: */
093: public abstract InstituteLocal getInstitute();
094:
095: /**
096: * @ejb.interface-method
097: */
098: public abstract void setInstitute(InstituteLocal institute);
099:
100: /**
101: * @ejb.interface-method
102: * @ejb.relation
103: * name="Department-Group-CompleteFKToPK"
104: * role-name="Department-has-Groups"
105: */
106: public abstract Collection getGroups();
107:
108: /**
109: * @ejb.interface-method
110: */
111: public abstract void setGroups(Collection groups);
112:
113: /**
114: * @ejb.interface-method
115: * @ejb.relation
116: * name="Department-Student-CompleteFKToPK"
117: * role-name="Department-has-Students"
118: */
119: public abstract Collection getStudents();
120:
121: /**
122: * @ejb.interface-method
123: */
124: public abstract void setStudents(Collection students);
125:
126: // EntityBean implementation ------------------------------------
127: /**
128: * @ejb.create-method
129: */
130: public DepartmentPK ejbCreate(String deptCode, String descr)
131: throws CreateException {
132: setDepartmentCode(deptCode);
133: setDepartmentCode2("X" + deptCode);
134: setDescription(descr);
135: return null;
136: }
137:
138: public void ejbPostCreate(String deptCode, String descr) {
139: }
140:
141: public void ejbActivate() throws EJBException, RemoteException {
142: }
143:
144: public void ejbLoad() throws EJBException, RemoteException {
145: }
146:
147: public void ejbPassivate() throws EJBException, RemoteException {
148: }
149:
150: public void ejbRemove() throws RemoveException, EJBException,
151: RemoteException {
152: }
153:
154: public void ejbStore() throws EJBException, RemoteException {
155: }
156:
157: public void setEntityContext(EntityContext ctx)
158: throws EJBException, RemoteException {
159: this .ctx = ctx;
160: }
161:
162: public void unsetEntityContext() throws EJBException,
163: RemoteException {
164: this.ctx = null;
165: }
166: }
|