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.foedeployer.ejb.o2mb;
023:
024: import javax.ejb.EntityBean;
025: import javax.ejb.EntityContext;
026: import javax.ejb.FinderException;
027: import javax.ejb.NoSuchEntityException;
028: import javax.ejb.ObjectNotFoundException;
029: import javax.ejb.RemoveException;
030: import javax.ejb.CreateException;
031: import javax.ejb.DuplicateKeyException;
032: import javax.ejb.EJBException;
033:
034: import javax.sql.DataSource;
035: import javax.naming.InitialContext;
036: import javax.naming.NamingException;
037:
038: import java.sql.Connection;
039: import java.sql.Statement;
040: import java.sql.ResultSet;
041: import java.sql.SQLException;
042:
043: import java.util.Set;
044:
045: import org.apache.log4j.Category;
046:
047: /**
048: * Models an employee.
049: *
050: * @ejb.bean
051: * name="Employee"
052: * generate="true"
053: * view-type="local"
054: * type="CMP"
055: * local-jndi-name="EmployeeEJB.EmployeeHome"
056: * reentrant="False"
057: * cmp-version="2.x"
058: * primkey-field="name"
059: *
060: * @ejb.pk
061: * class="java.lang.String"
062: * generate="false"
063: *
064: * @ejb.transaction type="Required"
065: *
066: * @@ejb.finder signature="Collection findAll()"
067: *
068: * @@ejb.persistence table-name="employee"
069: * @weblogic:table-name employee
070: *
071: * @jboss.create-table "${jboss.create.table}"
072: * @jboss.remove-table "${jboss.remove.table}"
073: *
074: * @author <a href="mailto:loubyansky@ua.fm">Alex Loubyansky</a>
075: */
076: public abstract class EmployeeBean implements EntityBean {
077: // Constants -----------------------------------------------------
078: static Category log = Category.getInstance(EmployeeBean.class);
079:
080: // Attributes ----------------------------------------------------
081: private EntityContext ctx;
082:
083: // CMP
084:
085: /**
086: * Employee's name: primary key field
087: *
088: * @ejb.pk-field
089: * @ejb.persistent-field
090: * @ejb.interface-method
091: *
092: * xdoclet needs to be updated
093: * @@ejb.persistence
094: * column-name="name"
095: * jdbc-type="VARCHAR"
096: * sql-type="VARCHAR(50)"
097: *
098: * @weblogic:dbms-column name
099: */
100: public abstract String getName();
101:
102: public abstract void setName(String name);
103:
104: // CMR
105:
106: /**
107: * Company: bidirectional CMR
108: *
109: * @ejb.interface-method
110: *
111: * @ejb.relation
112: * name="Company-Employee"
113: * role-name="Employee-Has-Company"
114: * cascade-delete="yes"
115: *
116: * @jboss.relation
117: * fk-constraint="false"
118: * related-pk-field="name"
119: * pk-column="company_name"
120: */
121: public abstract CompanyLocal getCompany();
122:
123: /**
124: * @ejb.interface-method
125: */
126: public abstract void setCompany(CompanyLocal company);
127:
128: // EntityBean Implementation -------------------------------------
129: /**
130: * @ejb.create-method
131: */
132: public String ejbCreate(String name) throws CreateException {
133: setName(name);
134: return null; // See 9.4.2 of the EJB 1.1 specification
135: }
136:
137: public void ejbPostCreate(String name) {
138: }
139:
140: public void ejbRemove() throws RemoveException {
141: log.debug("removed: " + ctx.getPrimaryKey());
142: }
143:
144: public void setEntityContext(EntityContext ctx) {
145: this .ctx = ctx;
146: }
147:
148: public void unsetEntityContext() {
149: ctx = null;
150: }
151:
152: public void ejbActivate() {
153: }
154:
155: public void ejbPassivate() {
156: }
157:
158: public void ejbLoad() {
159: }
160:
161: public void ejbStore() {
162: }
163: }
|