Hi, is there any example for using the unknown-pk feature of jboss3.2?
i attached my TestEntityBean.java thanx markus -- ------------------------------------------------------------------------------- Markus Garscha Germany pgp-keyid: 0xEE18AF3B -------------------------------------------------------------------------------
/*
* (C) 2003 Markus Garscha
*/
package test.entity;
import test.interfaces.*;
import java.sql.Date;
import java.rmi.RemoteException;
import java.util.Collection;
import java.util.Iterator;
import java.lang.Object;
import java.lang.Integer;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.*;
/**
* The Entity bean represents a TestEntity
*
* @author Andreas Schaefer
* @version $Revision: 1.1 $
*
* @ejb.bean
* name="TestEntity"
* display-name="TestEntity working on projects to support clients"
* type="CMP"
* jndi-name="ejb/test/TestEntity"
* view-type="both"
* cmp-version="2.x"
*
* @ejb.finder
* signature="java.util.Collection findAll()"
*
* @jboss.create-table "true"
* @jboss.remove-table "true"
*
* @jboss.unknown-pk
* class="java.lang.Integer"
* column-name="id"
* jdbc-type="INTEGER"
* sql-type="INTEGER"
* @jboss.entity-command
* name="pk-sql"
* @jboss.entity-command-attribute
* name="pk-sql"
* value="SELECT max(id)+1 FROM TestEntity"
*
**/
public abstract class TestEntityBean implements EntityBean {
public EntityContext mContext;
/**
* Retrieve the TestEntity's FirstName.
*
* @return Returns an int representing the FirstName of this TestEntity.
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="First_Name"
**/
public abstract String getFirstName();
/**
* Set the TestEntity's FirstName.
*
* @param pFirstName The FirstName of this TestEntity. Is set at creation time.
*
* @ejb.interface-method
* view-type="both"
**/
public abstract void setFirstName( String pFirstName );
/**
* Retrieve the TestEntity's LastName.
*
* @return Returns an int representing the LastName of this TestEntity.
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="Last_Name"
*
* @ejb.interface-method
* view-type="both"
**/
public abstract String getLastName();
/**
* Set the TestEntity's LastName.
*
* @param pLastName The LastName of this TestEntity. Is set at creation time.
*
* @ejb.interface-method
* view-type="both"
**/
public abstract void setLastName( String pLastName );
/**
* @ejb.create-method
* view-type="remote"
*/
public java.lang.Object ejbCreate() throws CreateException {
return null;
}
public void ejbPostCreate( TestEntityData pTestEntity ) {
System.out.println("ejbPostCreate: " + mContext.getPrimaryKey());
}
public void setEntityContext( EntityContext lContext ) { mContext = lContext; }
public void unsetEntityContext() { mContext = null; }
public void ejbActivate() { }
public void ejbPassivate() { }
public void ejbLoad() { }
public void ejbStore() { }
public void ejbRemove() throws RemoveException { }
}
msg04759/pgp00000.pgp
Description: PGP signature
