KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > cmp2 > ejbselect > BBean


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.ejbselect;
23
24 import java.util.Collection JavaDoc;
25 import javax.ejb.CreateException JavaDoc;
26 import javax.ejb.EntityBean JavaDoc;
27 import javax.ejb.EntityContext JavaDoc;
28 import javax.ejb.FinderException JavaDoc;
29 import javax.ejb.RemoveException JavaDoc;
30
31 /**
32  * @ejb.bean
33  * name="B"
34  * type="CMP"
35  * cmp-version="2.x"
36  * view-type="local"
37  * primkey-field="id"
38  * @ejb.pk generate="true"
39  * @ejb.util generate="physical"
40  * @ejb.persistence table-name="TEST_B"
41  * @jboss.persistence
42  * create-table="true"
43  * remove-table="true"
44  *
45  * @jboss.query
46  * signature="Collection ejbSelectDynamic(java.lang.String ql, java.lang.Object[] params)"
47  * dynamic="true"
48  *
49  * @author others + <a HREF="mailto:alex@jboss.org">Alex Loubyansky</a>
50  */

51 public abstract class BBean implements EntityBean JavaDoc
52 {
53    /**
54     * @ejb.pk-field
55     * @ejb.persistent-field
56     * @ejb.interface-method
57     * @ejb.persistence column-name="ID"
58     */

59    public abstract String JavaDoc getId();
60    public abstract void setId(String JavaDoc id);
61
62    /**
63     * @ejb.persistent-field
64     * @ejb.interface-method
65     */

66    public abstract String JavaDoc getName();
67    /**
68     * @ejb.interface-method
69     */

70    public abstract void setName(String JavaDoc name);
71
72    /**
73     * @ejb.persistent-field
74     * @ejb.interface-method
75     */

76    public abstract boolean getBool();
77    /**
78     * @ejb.interface-method
79     */

80    public abstract void setBool(boolean bool);
81
82    /**
83     * @ejb.persistent-field
84     * @ejb.interface-method
85     */

86    public abstract long getLongField();
87    /**
88     * @ejb.interface-method
89     */

90    public abstract void setLongField(long value);
91
92    /**
93     * @ejb.relation
94     * name="A-B"
95     * role-name="B-has-an-A"
96     * cascade-delete="true"
97     * @jboss.relation
98     * related-pk-field="id"
99     * fk-column="A_ID"
100     *
101     * @ejb.interface-method
102     */

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

107    public abstract void setA(ALocal a);
108
109    // ejbSelect methods
110

111    /**
112     * @ejb.select query="SELECT OBJECT(b) FROM B AS b WHERE b.bool = TRUE"
113     */

114    public abstract Collection JavaDoc ejbSelectTrue() throws FinderException JavaDoc;
115
116    /**
117     * @ejb.select query="SELECT OBJECT(b) FROM B AS b WHERE b.bool = FALSE"
118     */

119    public abstract Collection JavaDoc ejbSelectFalse() throws FinderException JavaDoc;
120
121    /**
122     * Dynamic QL
123     * @ejb.select query=""
124     */

125    public abstract Collection JavaDoc ejbSelectDynamic(String JavaDoc ql, Object JavaDoc[] params) throws FinderException JavaDoc;
126
127    // Interface methods
128

129    /**
130     * @ejb.interface-method
131     */

132    public Collection JavaDoc getTrue() throws FinderException JavaDoc
133    {
134       return ejbSelectTrue();
135    }
136
137    /**
138     * @ejb.interface-method
139     */

140    public Collection JavaDoc getFalse() throws FinderException JavaDoc
141    {
142       return ejbSelectFalse();
143    }
144
145    // Home methods
146

147    /**
148     * @ejb.home-method
149     */

150    public Collection JavaDoc ejbHomeSelectDynamic(String JavaDoc ql, Object JavaDoc[] params) throws FinderException JavaDoc
151    {
152       return ejbSelectDynamic(ql, params);
153    }
154
155    /**
156     * @ejb.create-method
157     */

158    public String JavaDoc ejbCreate(String JavaDoc id, String JavaDoc name, boolean bool)
159       throws CreateException JavaDoc
160    {
161       setId(id);
162       setName(name);
163       setBool(bool);
164       return null;
165    }
166
167    public void ejbPostCreate(String JavaDoc id, String JavaDoc name, boolean bool) {}
168
169    public void setEntityContext(EntityContext JavaDoc context) {}
170    public void unsetEntityContext() {}
171    public void ejbRemove() throws RemoveException JavaDoc {}
172    public void ejbActivate() {}
173    public void ejbPassivate() {}
174    public void ejbLoad() {}
175    public void ejbStore() {}
176 }
177
Popular Tags