001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.cmp2.ejbselect;
023:
024: import java.util.Collection;
025: import javax.ejb.CreateException;
026: import javax.ejb.EntityBean;
027: import javax.ejb.EntityContext;
028: import javax.ejb.FinderException;
029: import javax.ejb.RemoveException;
030:
031: /**
032: * @ejb.bean
033: * name="B"
034: * type="CMP"
035: * cmp-version="2.x"
036: * view-type="local"
037: * primkey-field="id"
038: * @ejb.pk generate="true"
039: * @ejb.util generate="physical"
040: * @ejb.persistence table-name="TEST_B"
041: * @jboss.persistence
042: * create-table="true"
043: * remove-table="true"
044: *
045: * @jboss.query
046: * signature="Collection ejbSelectDynamic(java.lang.String ql, java.lang.Object[] params)"
047: * dynamic="true"
048: *
049: * @author others + <a href="mailto:alex@jboss.org">Alex Loubyansky</a>
050: */
051: public abstract class BBean implements EntityBean {
052: /**
053: * @ejb.pk-field
054: * @ejb.persistent-field
055: * @ejb.interface-method
056: * @ejb.persistence column-name="ID"
057: */
058: public abstract String getId();
059:
060: public abstract void setId(String id);
061:
062: /**
063: * @ejb.persistent-field
064: * @ejb.interface-method
065: */
066: public abstract String getName();
067:
068: /**
069: * @ejb.interface-method
070: */
071: public abstract void setName(String name);
072:
073: /**
074: * @ejb.persistent-field
075: * @ejb.interface-method
076: */
077: public abstract boolean getBool();
078:
079: /**
080: * @ejb.interface-method
081: */
082: public abstract void setBool(boolean bool);
083:
084: /**
085: * @ejb.persistent-field
086: * @ejb.interface-method
087: */
088: public abstract long getLongField();
089:
090: /**
091: * @ejb.interface-method
092: */
093: public abstract void setLongField(long value);
094:
095: /**
096: * @ejb.relation
097: * name="A-B"
098: * role-name="B-has-an-A"
099: * cascade-delete="true"
100: * @jboss.relation
101: * related-pk-field="id"
102: * fk-column="A_ID"
103: *
104: * @ejb.interface-method
105: */
106: public abstract ALocal getA();
107:
108: /**
109: * @ejb.interface-method
110: */
111: public abstract void setA(ALocal a);
112:
113: // ejbSelect methods
114:
115: /**
116: * @ejb.select query="SELECT OBJECT(b) FROM B AS b WHERE b.bool = TRUE"
117: */
118: public abstract Collection ejbSelectTrue() throws FinderException;
119:
120: /**
121: * @ejb.select query="SELECT OBJECT(b) FROM B AS b WHERE b.bool = FALSE"
122: */
123: public abstract Collection ejbSelectFalse() throws FinderException;
124:
125: /**
126: * Dynamic QL
127: * @ejb.select query=""
128: */
129: public abstract Collection ejbSelectDynamic(String ql,
130: Object[] params) throws FinderException;
131:
132: // Interface methods
133:
134: /**
135: * @ejb.interface-method
136: */
137: public Collection getTrue() throws FinderException {
138: return ejbSelectTrue();
139: }
140:
141: /**
142: * @ejb.interface-method
143: */
144: public Collection getFalse() throws FinderException {
145: return ejbSelectFalse();
146: }
147:
148: // Home methods
149:
150: /**
151: * @ejb.home-method
152: */
153: public Collection ejbHomeSelectDynamic(String ql, Object[] params)
154: throws FinderException {
155: return ejbSelectDynamic(ql, params);
156: }
157:
158: /**
159: * @ejb.create-method
160: */
161: public String ejbCreate(String id, String name, boolean bool)
162: throws CreateException {
163: setId(id);
164: setName(name);
165: setBool(bool);
166: return null;
167: }
168:
169: public void ejbPostCreate(String id, String name, boolean bool) {
170: }
171:
172: public void setEntityContext(EntityContext context) {
173: }
174:
175: public void unsetEntityContext() {
176: }
177:
178: public void ejbRemove() throws RemoveException {
179: }
180:
181: public void ejbActivate() {
182: }
183:
184: public void ejbPassivate() {
185: }
186:
187: public void ejbLoad() {
188: }
189:
190: public void ejbStore() {
191: }
192: }
|