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.fkmapping.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="ChildUPK"
032: * type="CMP"
033: * cmp-version="2.x"
034: * view-type="local"
035: * reentrant="false"
036: * @ejb.pk
037: * class="java.lang.Object"
038: * generate="false"
039: * @ejb.util generate="physical"
040: * @ejb.persistence table-name="CHILD_UPK"
041: * @jboss.persistence
042: * create-table="true"
043: * remove-table="true"
044: * @ejb:transaction-type type="Container"
045: * @jboss.container-configuration name="INSERT after ejbPostCreate Container"
046: *
047: * @jboss.unknown-pk class="java.lang.String"
048: * @jboss.entity-command name="key-generator"
049: *
050: * @author <a href="mailto:alex@jboss.org">Alex Loubyansky</a>
051: */
052: public abstract class ChildCMPUnknownPKBean implements EntityBean {
053: // Attributes -----------------------------------------------
054: private EntityContext ctx;
055:
056: // CMP accessors --------------------------------------------
057: /**
058: * @ejb.persistent-field
059: * @ejb.interface-method
060: * @ejb.persistence column-name="FIRST_NAME"
061: */
062: public abstract String getFirstName();
063:
064: public abstract void setFirstName(String name);
065:
066: /**
067: * @ejb.interface-method
068: * @ejb.relation
069: * name="Father-Child-upk"
070: * role-name="Child-has-Father"
071: * target-ejb="Parent"
072: * target-role-name="Father-has-Child"
073: * target-multiple="yes"
074: * cascade-delete="no"
075: * @jboss.relation
076: * related-pk-field="id"
077: * fk-column="FATHER_ID"
078: * @jboss.relation
079: * related-pk-field="firstName"
080: * fk-column="FATHER_NAME"
081: */
082: public abstract ParentLocal getFather();
083:
084: /**
085: * @ejb.interface-method
086: */
087: public abstract void setFather(ParentLocal parent);
088:
089: /**
090: * @ejb.interface-method
091: * @ejb.relation
092: * name="Mother-Child-upk"
093: * role-name="Child-has-Mother"
094: * target-ejb="Parent"
095: * target-role-name="Mother-has-Child"
096: * target-multiple="yes"
097: * cascade-delete="no"
098: * @jboss.relation
099: * related-pk-field="id"
100: * fk-column="MOTHER_ID"
101: * @jboss.relation
102: * related-pk-field="firstName"
103: * fk-column="MOTHER_NAME"
104: */
105: public abstract ParentLocal getMother();
106:
107: /**
108: * @ejb.interface-method
109: */
110: public abstract void setMother(ParentLocal parent);
111:
112: // EntityBean implementation -------------------------------------
113: /**
114: * @ejb.create-method
115: */
116: public Object ejbCreate(String firstName) throws CreateException {
117: setFirstName(firstName);
118: return null;
119: }
120:
121: public void ejbPostCreate(Long id, String firstName) {
122: }
123:
124: /**
125: * @param ctx The new entityContext value
126: */
127: public void setEntityContext(EntityContext ctx) {
128: this .ctx = ctx;
129: }
130:
131: /**
132: * Unset the associated entity context.
133: */
134: public void unsetEntityContext() {
135: this .ctx = null;
136: }
137:
138: public void ejbActivate() {
139: }
140:
141: public void ejbLoad() {
142: }
143:
144: public void ejbPassivate() {
145: }
146:
147: public void ejbRemove() throws RemoveException {
148: }
149:
150: public void ejbStore() {
151: }
152: }
|