KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > fkstackoverflow > ejb > SimpleParentBean


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.fkstackoverflow.ejb;
23
24 import org.jboss.logging.Logger;
25
26 import javax.ejb.EntityBean JavaDoc;
27 import javax.ejb.EntityContext JavaDoc;
28 import javax.ejb.RemoveException JavaDoc;
29 import javax.ejb.CreateException JavaDoc;
30 import java.util.Collection JavaDoc;
31
32
33 /**
34  * @ejb.bean
35  * name="SimpleParent"
36  * type="CMP"
37  * cmp-version="2.x"
38  * view-type="local"
39  * reentrant="false"
40  * primkey-field="id"
41  * @ejb.pk generate="false"
42  * @ejb.util generate="physical"
43  * @ejb.persistence table-name="PARENT"
44  * @ejb:transaction type="Required"
45  * @ejb:transaction-type type="Container"
46  * @jboss.persistence
47  * create-table="true"
48  * remove-table="true"
49  */

50 public abstract class SimpleParentBean
51    implements EntityBean JavaDoc
52 {
53    Logger log = Logger.getLogger(SimpleParentBean.class);
54    private EntityContext JavaDoc ctx;
55
56    // CMP accessors
57

58    /**
59     * @ejb.pk-field
60     * @ejb.persistent-field
61     * @ejb.interface-method
62     * @ejb.persistence column-name="PARENT_ID"
63     */

64    public abstract Long JavaDoc getId();
65    public abstract void setId(Long JavaDoc id);
66
67    /**
68     * @ejb.persistent-field
69     * @ejb.interface-method
70     * @ejb.persistence column-name="FIRST_NAME"
71     */

72    public abstract String JavaDoc getFirstName();
73    /**
74     * @ejb.interface-method
75     */

76    public abstract void setFirstName(String JavaDoc firstName);
77
78    // CMR
79

80    /**
81     * @ejb.interface-method
82     * @ejb.relation
83     * name="parent-children-simple1"
84     * role-name="parent-has-children"
85     */

86    public abstract Collection JavaDoc getChildren1();
87    /**
88     * @ejb.interface-method
89     */

90    public abstract void setChildren1(Collection JavaDoc children);
91
92    /**
93     * @ejb.interface-method
94     * @ejb.relation
95     * name="parent-children-simple2"
96     * role-name="parent-has-children"
97     */

98    public abstract Collection JavaDoc getChildren2();
99    /**
100     * @ejb.interface-method
101     */

102    public abstract void setChildren2(Collection JavaDoc children);
103
104    // EntityBean implementation
105

106    /**
107     * @ejb.create-method
108     */

109    public Long JavaDoc ejbCreate(Long JavaDoc id, String JavaDoc firstName)
110       throws CreateException JavaDoc
111    {
112       setId(id);
113       setFirstName(firstName);
114       return null;
115    }
116
117    public void ejbPostCreate(Long JavaDoc id, String JavaDoc firstName)
118    {
119    }
120
121    /**
122     * @param ctx The new entityContext value
123     */

124    public void setEntityContext(EntityContext JavaDoc ctx)
125    {
126       this.ctx = ctx;
127    }
128
129    /**
130     * Unset the associated entity context.
131     */

132    public void unsetEntityContext()
133    {
134       this.ctx = null;
135    }
136
137    public void ejbActivate() {}
138    public void ejbLoad() {}
139    public void ejbPassivate() {}
140    public void ejbRemove() throws RemoveException JavaDoc {}
141    public void ejbStore() {}
142 }
143
Popular Tags