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.enums.ejb;
023:
024: import javax.ejb.EntityBean;
025: import javax.ejb.EntityContext;
026: import javax.ejb.RemoveException;
027: import javax.ejb.CreateException;
028:
029: /**
030: * @ejb.bean
031: * name="Child"
032: * type="CMP"
033: * cmp-version="2.x"
034: * view-type="local"
035: * reentrant="false"
036: * primkey-field="id"
037: * @ejb.pk generate="false"
038: * @ejb.util generate="physical"
039: * @ejb.persistence table-name="CHILD"
040: * @jboss.persistence
041: * datasource="${ds.name}"
042: * datasource-mapping="${ds.mapping}"
043: * create-table="${jboss.create.table}"
044: * remove-table="${jboss.remove.table}"
045: * @ejb:transaction-type type="Container"
046: *
047: * @ejb.finder
048: * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
049: * query="select object(o) from Child o where o.color=?1"
050: *
051: * @ejb.finder
052: * signature="org.jboss.test.cmp2.ejb.ChildLocal findByColorDeclaredSql(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
053: * query="select object(o) from Child o where o.color=?1"
054: *
055: * @ejb.finder
056: * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
057: * query="select object(o) from Child o where o.color<?1"
058: * @jboss.query
059: * signature="java.util.Collection findLowColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
060: * query="select object(o) from Child o where o.color<?1"
061: *
062: * @ejb.finder
063: * signature="org.jboss.test.cmp2.ejb.ChildLocal findAndOrderByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
064: * query="select object(o) from Child o where o.color = ?1"
065: * @jboss.query
066: * signature="org.jboss.test.cmp2.ejb.ChildLocal findAndOrderByColor(org.jboss.test.cmp2.enums.ejb.ColorEnum color)"
067: * query="select object(o) from Child o where o.color = ?1 order by o.color"
068: *
069: * @author <a href="mailto:alex@jboss.org">Alex Loubyansky</a>
070: * @author <a href="mailto:gturner@unzane.com">Gerald Turner</a>
071: */
072: public abstract class ChildCMPBean implements EntityBean {
073: // Attributes -----------------------------------------------
074: private EntityContext ctx;
075:
076: // CMP accessors --------------------------------------------
077: /**
078: * @ejb.pk-field
079: * @ejb.persistent-field
080: * @ejb.interface-method
081: * @ejb.persistence column-name="CHILD_ID"
082: */
083: public abstract IDClass getId();
084:
085: public abstract void setId(IDClass id);
086:
087: /**
088: * @ejb.persistent-field
089: * @ejb.interface-method
090: * @ejb.persistence column-name="COLOR_ID"
091: */
092: public abstract ColorEnum getColor();
093:
094: /**
095: * @ejb.interface-method
096: */
097: public abstract void setColor(ColorEnum color);
098:
099: /**
100: * @ejb.persistent-field
101: * @ejb.interface-method
102: * @ejb.persistence column-name="ANIMAL_ID"
103: */
104: public abstract AnimalEnum getAnimal();
105:
106: /**
107: * @ejb.interface-method
108: */
109: public abstract void setAnimal(AnimalEnum animal);
110:
111: // EntityBean implementation -------------------------------------
112: /**
113: * @ejb.create-method
114: * @throws CreateException
115: */
116: public IDClass ejbCreate(IDClass childId) throws CreateException {
117: setId(childId);
118: setColor(ColorEnum.RED);
119: setAnimal(AnimalEnum.PENGUIN);
120: return null;
121: }
122:
123: public void ejbPostCreate(IDClass childId) {
124: }
125:
126: /**
127: * @param ctx The new entityContext value
128: */
129: public void setEntityContext(EntityContext ctx) {
130: this .ctx = ctx;
131: }
132:
133: /**
134: * Unset the associated entity context.
135: */
136: public void unsetEntityContext() {
137: this .ctx = null;
138: }
139:
140: public void ejbActivate() {
141: }
142:
143: public void ejbLoad() {
144: }
145:
146: public void ejbPassivate() {
147: }
148:
149: public void ejbRemove() throws RemoveException {
150: }
151:
152: public void ejbStore() {
153: }
154: }
|