KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > enums > ejb > ChildCMPBean


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.enums.ejb;
23
24 import javax.ejb.EntityBean JavaDoc;
25 import javax.ejb.EntityContext JavaDoc;
26 import javax.ejb.RemoveException JavaDoc;
27 import javax.ejb.CreateException JavaDoc;
28
29
30 /**
31  * @ejb.bean
32  * name="Child"
33  * type="CMP"
34  * cmp-version="2.x"
35  * view-type="local"
36  * reentrant="false"
37  * primkey-field="id"
38  * @ejb.pk generate="false"
39  * @ejb.util generate="physical"
40  * @ejb.persistence table-name="CHILD"
41  * @jboss.persistence
42  * datasource="${ds.name}"
43  * datasource-mapping="${ds.mapping}"
44  * create-table="${jboss.create.table}"
45  * remove-table="${jboss.remove.table}"
46  * @ejb:transaction-type type="Container"
47  *
48  * @ejb.finder
49  * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
50  * query="select object(o) from Child o where o.color=?1"
51  *
52  * @ejb.finder
53  * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColorDeclaredSql(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
54  * query="select object(o) from Child o where o.color=?1"
55  *
56  * @ejb.finder
57  * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
58  * query="select object(o) from Child o where o.color<?1"
59  * @jboss.query
60  * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
61  * query="select object(o) from Child o where o.color<?1"
62  *
63  * @ejb.finder
64  * signature="org.jboss.test.cmp2.ejb.ChildLocal findAndOrderByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
65  * query="select object(o) from Child o where o.color = ?1"
66  * @jboss.query
67  * signature="org.jboss.test.cmp2.ejb.ChildLocal findAndOrderByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
68  * query="select object(o) from Child o where o.color = ?1 order by o.color"
69  *
70  * @author <a HREF="mailto:alex@jboss.org">Alex Loubyansky</a>
71  * @author <a HREF="mailto:gturner@unzane.com">Gerald Turner</a>
72  */

73 public abstract class ChildCMPBean
74    implements EntityBean JavaDoc
75 {
76    // Attributes -----------------------------------------------
77
private EntityContext JavaDoc ctx;
78
79    // CMP accessors --------------------------------------------
80
/**
81     * @ejb.pk-field
82     * @ejb.persistent-field
83     * @ejb.interface-method
84     * @ejb.persistence column-name="CHILD_ID"
85     */

86    public abstract IDClass getId();
87
88    public abstract void setId(IDClass id);
89
90    /**
91     * @ejb.persistent-field
92     * @ejb.interface-method
93     * @ejb.persistence column-name="COLOR_ID"
94     */

95    public abstract ColorEnum getColor();
96
97    /**
98     * @ejb.interface-method
99     */

100    public abstract void setColor(ColorEnum color);
101
102    /**
103     * @ejb.persistent-field
104     * @ejb.interface-method
105     * @ejb.persistence column-name="ANIMAL_ID"
106     */

107    public abstract AnimalEnum getAnimal();
108
109    /**
110     * @ejb.interface-method
111     */

112    public abstract void setAnimal(AnimalEnum animal);
113
114    // EntityBean implementation -------------------------------------
115
/**
116     * @ejb.create-method
117     * @throws CreateException
118     */

119    public IDClass ejbCreate(IDClass childId)
120       throws CreateException JavaDoc
121    {
122       setId(childId);
123       setColor(ColorEnum.RED);
124       setAnimal(AnimalEnum.PENGUIN);
125       return null;
126    }
127
128    public void ejbPostCreate(IDClass childId)
129    {
130    }
131
132    /**
133     * @param ctx The new entityContext value
134     */

135    public void setEntityContext(EntityContext JavaDoc ctx)
136    {
137       this.ctx = ctx;
138    }
139
140    /**
141     * Unset the associated entity context.
142     */

143    public void unsetEntityContext()
144    {
145       this.ctx = null;
146    }
147
148    public void ejbActivate()
149    {
150    }
151
152    public void ejbLoad()
153    {
154    }
155
156    public void ejbPassivate()
157    {
158    }
159
160    public void ejbRemove() throws RemoveException JavaDoc
161    {
162    }
163
164    public void ejbStore()
165    {
166    }
167 }
168
Popular Tags