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