AutoGenerating PK & Oracle
--1, the EJB Test:
import javax.ejb.EntityBean;
/**
* @ejb.bean name="Test"
* jndi-name="TestBean"
* type="CMP"
* primkey-field="id"
* schema="testSchema"
* cmp-version="2.x"
*
* @ejb.persistence
* table-name="SVD_TEST"
*
* @ejb.finder
* query="SELECT OBJECT(a) FROM testSchema as a"
* signature="java.util.Collection findAll()"
*
* @jboss.entity-command name="oracle-sequence"
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand"
* @jboss.entity-command-attribute name="sequence" value="SEQ_SVD_TEST"
*
**/
public abstract class TestBean implements EntityBean {
/**
* The ejbCreate method.
*
* @ejb.create-method
*/
public java.lang.Integer ejbCreate(Integer id, String nombre) throws
javax.ejb.CreateException {
setId(id);
setNombre(nombre);
return null;
}
/**
* The container invokes this method immediately after it calls ejbCreate.
*
*/
public void ejbPostCreate(Integer id, String nombre) throws
javax.ejb.CreateException {}
/**
* Returns the id
* @return the id
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="ID"
* sql-type="NUMBER"
* @ejb.pk-field
* @ejb.interface-method
*/
public abstract java.lang.Integer getId();
/**
* Sets the id
*
* @param java.lang.Integer the new id value
*
* @ejb.interface-method
*/
public abstract void setId(java.lang.Integer id);
/**
* Returns the nombre
* @return the nombre
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="NOMBRE"
* sql-type="VARCHAR2"
*
* @ejb.interface-method
*/
public abstract java.lang.String getNombre();
/**
* Sets the nombre
*
* @param java.lang.String the new nombre value
*
* @ejb.interface-method
*/
public abstract void setNombre(java.lang.String nombre);
}
--2, the jbosscmp-jdbc.xml
<ejb-name>Test</ejb-name>
<table-name>SVD_TEST</table-name>
<cmp-field>
<field-name>nombre</field-name>
<column-name>NOMBRE</column-name>
</cmp-field>
<unknown-pk>
<unknown-pk-class>java.lang.Integer</unknown-pk-class>
<field-name>id</field-name>
<column-name>ID</column-name>
<jdbc-type>INTEGER</jdbc-type>
<sql-type>NUMBER</sql-type>
<auto-increment/>
</unknown-pk>
<entity-command name="oracle-sequence"
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand">
SEQ_SVD_TEST
</entity-command>
--3, in the section: <entity-commands>, file:
\jboss-3.2.3\server\all\conf\standardjbosscmp-jdbc.xml
<entity-commands>
<entity-command name="oracle-sequence"
class="org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCOracleCreateCommand">
SEQ_SVD_TEST
</entity-command>
</entity-commands>
--4, in Oracle, create the sequence: SEQ_SVD_TEST
CREATE SEQUENCE SEQ_SVD_TEST
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 1E17
NOCACHE
CYCLE ORDER;
--5, Ready.
Creo que esto es todo.
Yo tengo implementado esto utilizando Oracle9i, JBOSS 3.2.3 y The Ecplipse project
como IDE y funciona perfecto.
See you.
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3837450#3837450
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3837450
-------------------------------------------------------
This SF.Net email is sponsored by the new InstallShield X.
>From Windows to Linux, servers to mobile, InstallShield X is the one
installation-authoring solution that does it all. Learn more and
evaluate today! http://www.installshield.com/Dev2Dev/0504
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user