KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > fkmapping > ejb > StudentEntityBean


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.fkmapping.ejb;
23
24 import javax.ejb.EntityContext JavaDoc;
25 import javax.ejb.EntityBean JavaDoc;
26 import javax.ejb.EJBException JavaDoc;
27 import javax.ejb.RemoveException JavaDoc;
28 import javax.ejb.CreateException JavaDoc;
29 import java.rmi.RemoteException JavaDoc;
30
31 /**
32  * @ejb.bean
33  * name="Student"
34  * type="CMP"
35  * cmp-version="2.x"
36  * view-type="local"
37  * reentrant="false"
38  * local-jndi-name="Student"
39  * @ejb.pk generate="true"
40  * @ejb.util generate="physical"
41  * @ejb.persistence table-name="STUDENT"
42  * @jboss.persistence
43  * create-table="true"
44  * remove-table="true"
45  *
46  * @author <a HREF="mailto:alex@jboss.org">Alex Loubyansky</a>
47  */

48 public abstract class StudentEntityBean
49    implements EntityBean JavaDoc
50 {
51    // Attributes ---------------------------------------------------
52
private EntityContext JavaDoc ctx;
53
54    // CMP accessors
55
/**
56     * @ejb.pk-field
57     * @ejb.persistent-field
58     * @ejb.interface-method
59     * @ejb.persistence column-name="DEPT_CODE"
60     */

61    public abstract String JavaDoc getDepartmentCode();
62    public abstract void setDepartmentCode(String JavaDoc deptCode);
63
64    /**
65     * @ejb.pk-field
66     * @ejb.persistent-field
67     * @ejb.interface-method
68     * @ejb.persistence column-name="DEPT_CODE2"
69     */

70    public abstract String JavaDoc getDepartmentCode2();
71    public abstract void setDepartmentCode2(String JavaDoc deptCode);
72
73    /**
74     * @ejb.pk-field
75     * @ejb.persistent-field
76     * @ejb.interface-method
77     * @ejb.persistence column-name="LAST_NAME"
78     */

79    public abstract String JavaDoc getLastName();
80    public abstract void setLastName(String JavaDoc lastName);
81
82    /**
83     * @ejb.persistent-field
84     * @ejb.interface-method
85     * @ejb.persistence column-name="DESCR"
86     */

87    public abstract String JavaDoc getDescription();
88    public abstract void setDescription(String JavaDoc description);
89
90    // CMR accessors
91
/**
92     * @ejb.interface-method
93     * @ejb.relation
94     * name="Department-Student-CompleteFKToPK"
95     * role-name="Student-has-Department"
96     * @jboss.relation
97     * fk-column="DEPT_CODE"
98     * related-pk-field="departmentCode"
99     * @jboss.relation
100     * fk-column="DEPT_CODE2"
101     * related-pk-field="departmentCode2"
102     */

103    public abstract DepartmentLocal getDepartment();
104    /**
105     * @ejb.interface-method
106     */

107    public abstract void setDepartment(DepartmentLocal department);
108
109    /**
110     * @ejb.interface-method
111     * @ejb.relation
112     * name="Group-Student-PartialFKToPK"
113     * role-name="Student-has-Group"
114     * @jboss.relation
115     * fk-column="DEPT_CODE"
116     * related-pk-field="departmentCode"
117     * @jboss.relation
118     * fk-column="DEPT_CODE2"
119     * related-pk-field="departmentCode2"
120     * @jboss.relation
121     * fk-column="GROUP_NUM_FK"
122     * related-pk-field="groupNumber"
123     */

124     public abstract GroupLocal getGroup();
125    /**
126     * @ejb.interface-method
127     */

128    public abstract void setGroup(GroupLocal group);
129
130    // EntityBean implementation ------------------------------------
131
/**
132     * @ejb.create-method
133     */

134    public StudentPK ejbCreate(String JavaDoc deptCode, String JavaDoc lastName, String JavaDoc descr)
135       throws CreateException JavaDoc
136    {
137       setDepartmentCode(deptCode);
138       setDepartmentCode2("X"+deptCode);
139       setLastName(lastName);
140       setDescription(descr);
141       return null;
142    }
143
144    public void ejbPostCreate(String JavaDoc deptCode, String JavaDoc lastName, String JavaDoc descr) {}
145
146    public void ejbActivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
147    public void ejbLoad() throws EJBException JavaDoc, RemoteException JavaDoc {}
148    public void ejbPassivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
149    public void ejbRemove() throws RemoveException JavaDoc, EJBException JavaDoc, RemoteException JavaDoc {}
150    public void ejbStore() throws EJBException JavaDoc, RemoteException JavaDoc {}
151    public void setEntityContext(EntityContext JavaDoc ctx) throws EJBException JavaDoc, RemoteException JavaDoc
152    {
153       this.ctx = ctx;
154    }
155    public void unsetEntityContext() throws EJBException JavaDoc, RemoteException JavaDoc
156    {
157       this.ctx = null;
158    }
159 }
160
Popular Tags