KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Collection JavaDoc;
31
32 /**
33  * @ejb.bean
34  * name="Department"
35  * type="CMP"
36  * cmp-version="2.x"
37  * view-type="local"
38  * reentrant="false"
39  * local-jndi-name="Department"
40  * @ejb.pk generate="true"
41  * @ejb.util generate="physical"
42  * @ejb.persistence table-name="DEPARTMENT"
43  * @jboss.persistence
44  * create-table="true"
45  * remove-table="true"
46  *
47  * @author <a HREF="mailto:alex@jboss.org">Alex Loubyansky</a>
48  */

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

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

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

79    public abstract String JavaDoc getDescription();
80    public abstract void setDescription(String JavaDoc description);
81
82    // CMR accessors
83
/**
84     * @ejb.interface-method
85     * @ejb.relation
86     * name="Institute-Department-StandaloneFK"
87     * role-name="Department-has-Institute"
88     * @jboss.relation
89     * fk-column="INST_ID_FK"
90     * related-pk-field="instituteId"
91     */

92    public abstract InstituteLocal getInstitute();
93    /**
94     * @ejb.interface-method
95     */

96    public abstract void setInstitute(InstituteLocal institute);
97
98    /**
99     * @ejb.interface-method
100     * @ejb.relation
101     * name="Department-Group-CompleteFKToPK"
102     * role-name="Department-has-Groups"
103     */

104    public abstract Collection JavaDoc getGroups();
105    /**
106     * @ejb.interface-method
107     */

108    public abstract void setGroups(Collection JavaDoc groups);
109
110    /**
111     * @ejb.interface-method
112     * @ejb.relation
113     * name="Department-Student-CompleteFKToPK"
114     * role-name="Department-has-Students"
115     */

116    public abstract Collection JavaDoc getStudents();
117    /**
118     * @ejb.interface-method
119     */

120    public abstract void setStudents(Collection JavaDoc students);
121
122    // EntityBean implementation ------------------------------------
123
/**
124     * @ejb.create-method
125     */

126    public DepartmentPK ejbCreate(String JavaDoc deptCode, String JavaDoc descr)
127       throws CreateException JavaDoc
128    {
129       setDepartmentCode(deptCode);
130       setDepartmentCode2("X"+deptCode);
131       setDescription(descr);
132       return null;
133    }
134
135    public void ejbPostCreate(String JavaDoc deptCode, String JavaDoc descr) {}
136
137    public void ejbActivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
138    public void ejbLoad() throws EJBException JavaDoc, RemoteException JavaDoc {}
139    public void ejbPassivate() throws EJBException JavaDoc, RemoteException JavaDoc {}
140    public void ejbRemove() throws RemoveException JavaDoc, EJBException JavaDoc, RemoteException JavaDoc {}
141    public void ejbStore() throws EJBException JavaDoc, RemoteException JavaDoc {}
142    public void setEntityContext(EntityContext JavaDoc ctx) throws EJBException JavaDoc, RemoteException JavaDoc
143    {
144       this.ctx = ctx;
145    }
146    public void unsetEntityContext() throws EJBException JavaDoc, RemoteException JavaDoc
147    {
148       this.ctx = null;
149    }
150 }
151
Popular Tags