You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by Radu Dumitrescu <rd...@pss.ro> on 2006/10/20 13:03:16 UTC

CMP EJB with identity primary key

Hello,

I want to use a CMP EJB with an identity primary key field. I am using derby database and geronimo 1.1.1. I modified the ejbCreate method and took out the id field so now it contains only the other fields:

public java.lang.Integer ejbCreate(String name, String description, Double price) throws javax.ejb.CreateException {
  setName(name);
  setDescription(description);
  setPrice(price);
  return null;
}

I also include the openejb-jar.xml section for this bean:
 <enterprise-beans>
   <entity>
   <ejb-name>Product</ejb-name> 
   <jndi-name>Product</jndi-name> 
   <table-name>APP.PRODUCTS</table-name>
   <cmp-field-mapping>
  <cmp-field-name>id</cmp-field-name>
  <table-column>ID</table-column>
 </cmp-field-mapping>
 <cmp-field-mapping>
  <cmp-field-name>name</cmp-field-name>
  <table-column>NAME</table-column>
 </cmp-field-mapping>
   <cmp-field-mapping>
  <cmp-field-name>description</cmp-field-name>
  <table-column>DESCRIPTION</table-column>
 </cmp-field-mapping>
 <cmp-field-mapping>
  <cmp-field-name>price</cmp-field-name>
  <table-column>PRICE</table-column>
 </cmp-field-mapping>
 <primkey-field>id</primkey-field>
 <key-generator>
  <auto-increment-table>
   <sql>INSERT INTO APP.PRODUCTS (NAME, DESCRIPTION, PRICE) VALUES (?, ?, ?)</sql>
   <return-type>java.lang.Integer</return-type>
  </auto-increment-table>
 </key-generator>
  <resource-ref>
    <ref-name>jdbc/BankDataSource</ref-name> 
    <resource-link>BankPool</resource-link> 
   </resource-ref>
   </entity>
  </enterprise-beans>

When I try to create a new bean like: 
home.create("Test name", "Test description", new Double(20.0));

I get a whole bunch of exceptions:

13:01:45,625 WARN  [GeronimoConnectionEventListener] connectionErrorOccurred called with null
ERROR 07000: At least one parameter to the current statement is uninitialized.
 at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
 at org.apache.derby.impl.sql.execute.BaseActivation.throwIfMissingParms(Unknown Source)
 at org.apache.derby.exe.ac601a400fx010ex652ax545bxffff8a29ac840.execute(Unknown Source)
 at org.apache.derby.impl.sql.GenericActivationHolder.execute(Unknown Source)
 at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
 at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
 at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
 at org.apache.derby.impl.jdbc.EmbedStatement.executeUpdate(Unknown Source)
 at org.tranql.connector.jdbc.StatementHandle.executeUpdate(StatementHandle.java:175)
 at org.tranql.pkgenerator.AutoIncrementTablePrimaryKeyGenerator.getNextPrimaryKey(AutoIncrementTablePrimaryKeyGenerator.java:56)
 at org.openejb.entity.cmp.CMPCreateMethod.execute(CMPCreateMethod.java:171)
 at org.openejb.dispatch.DispatchInterceptor.invoke(DispatchInterceptor.java:72)
 at org.apache.geronimo.naming.java.ComponentContextInterceptor.invoke(ComponentContextInterceptor.java:56)
 at org.openejb.ConnectionTrackingInterceptor.invoke(ConnectionTrackingInterceptor.java:81)
 at org.openejb.entity.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:136)
 at org.openejb.entity.cmp.InTxCacheInterceptor.invoke(InTxCacheInterceptor.java:90)
 at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:140)
 at org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
 at org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
 at org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
 at org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:297)
 at org.openejb.server.ejbd.EjbRequestHandler.doEjbHome_CREATE(EjbRequestHandler.java:342)
 at org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:205)
 at org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
 at org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
 at org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.activeio.xnet.ServerService$$EnhancerByCGLIB$$860a25cd.service(<generated>)
 at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
 at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
 at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:172)
 at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:289)
 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:595)
13:01:45,625 ERROR [Transaction] Unexpected exception rolling back org.apache.geronimo.connector.outbound.LocalXAResource@589375; continuing with rollback
javax.transaction.xa.XAException
 at org.apache.geronimo.connector.outbound.LocalXAResource.rollback(LocalXAResource.java:88)
 at org.apache.geronimo.transaction.manager.TransactionImpl.rollbackResources(TransactionImpl.java:542)
 at org.apache.geronimo.transaction.manager.TransactionImpl.rollback(TransactionImpl.java:446)
 at org.apache.geronimo.transaction.manager.TransactionManagerImpl.rollback(TransactionManagerImpl.java:155)
 at org.apache.geronimo.transaction.manager.TransactionManagerImpl$$FastClassByCGLIB$$14ee5fe0.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.apache.geronimo.transaction.manager.XidImporter$$EnhancerByCGLIB$$9bb8a3ba.rollback(<generated>)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.isRolledback(InheritableTransactionContext.java:283)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.complete(InheritableTransactionContext.java:171)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.commit(InheritableTransactionContext.java:146)
 at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:152)
 at org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
 at org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
 at org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
 at org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:297)
 at org.openejb.server.ejbd.EjbRequestHandler.doEjbHome_CREATE(EjbRequestHandler.java:342)
 at org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:205)
 at org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
 at org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
 at org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.activeio.xnet.ServerService$$EnhancerByCGLIB$$860a25cd.service(<generated>)
 at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
 at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
 at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:172)
 at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:289)
 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:595)
Caused by: javax.resource.spi.LocalTransactionException: Unable to rollback
 at org.tranql.connector.jdbc.ManagedJDBCConnection.localTransactionRollback(ManagedJDBCConnection.java:113)
 at org.tranql.connector.AbstractManagedConnection$LocalTransactionImpl.rollback(AbstractManagedConnection.java:196)
 at org.apache.geronimo.connector.outbound.LocalXAResource.rollback(LocalXAResource.java:86)
 ... 39 more
Caused by: SQL Exception: No current connection.
 at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
 at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
 at org.apache.derby.impl.jdbc.Util.noCurrentConnection(Unknown Source)
 at org.apache.derby.impl.jdbc.EmbedConnection.setupContextStack(Unknown Source)
 at org.apache.derby.impl.jdbc.EmbedConnection.rollback(Unknown Source)
 at org.tranql.connector.jdbc.ManagedJDBCConnection.localTransactionRollback(ManagedJDBCConnection.java:111)
 ... 41 more
13:01:45,625 ERROR [AbstractTransactionContext] Unable to roll back transaction
java.lang.IllegalStateException: Status is STATUS_NO_TRANSACTION
 at org.apache.geronimo.transaction.manager.TransactionImpl.rollback(TransactionImpl.java:438)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.rollbackAndThrow(InheritableTransactionContext.java:308)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.complete(InheritableTransactionContext.java:199)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.commit(InheritableTransactionContext.java:146)
 at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:152)
 at org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
 at org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
 at org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
 at org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:297)
 at org.openejb.server.ejbd.EjbRequestHandler.doEjbHome_CREATE(EjbRequestHandler.java:342)
 at org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:205)
 at org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
 at org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
 at org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.activeio.xnet.ServerService$$EnhancerByCGLIB$$860a25cd.service(<generated>)
 at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
 at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
 at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:172)
 at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:289)
 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:595)
13:01:45,671 WARN  [SystemExceptionInterceptor] Product
javax.transaction.SystemException
 at org.apache.geronimo.transaction.manager.TransactionImpl.rollbackResources(TransactionImpl.java:546)
 at org.apache.geronimo.transaction.manager.TransactionImpl.rollback(TransactionImpl.java:446)
 at org.apache.geronimo.transaction.manager.TransactionManagerImpl.rollback(TransactionManagerImpl.java:155)
 at org.apache.geronimo.transaction.manager.TransactionManagerImpl$$FastClassByCGLIB$$14ee5fe0.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.apache.geronimo.transaction.manager.XidImporter$$EnhancerByCGLIB$$9bb8a3ba.rollback(<generated>)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.isRolledback(InheritableTransactionContext.java:283)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.complete(InheritableTransactionContext.java:171)
 at org.apache.geronimo.transaction.context.InheritableTransactionContext.commit(InheritableTransactionContext.java:146)
 at org.openejb.transaction.ContainerPolicy$TxRequired.invoke(ContainerPolicy.java:152)
 at org.openejb.transaction.TransactionContextInterceptor.invoke(TransactionContextInterceptor.java:80)
 at org.openejb.SystemExceptionInterceptor.invoke(SystemExceptionInterceptor.java:82)
 at org.openejb.GenericEJBContainer.invoke(GenericEJBContainer.java:238)
 at org.openejb.server.ejbd.EjbRequestHandler.invoke(EjbRequestHandler.java:297)
 at org.openejb.server.ejbd.EjbRequestHandler.doEjbHome_CREATE(EjbRequestHandler.java:342)
 at org.openejb.server.ejbd.EjbRequestHandler.processRequest(EjbRequestHandler.java:205)
 at org.openejb.server.ejbd.EjbDaemon.service(EjbDaemon.java:150)
 at org.openejb.server.ejbd.EjbServer.service(EjbServer.java:87)
 at org.openejb.server.ejbd.EjbServer$$FastClassByCGLIB$$d379d2ff.invoke(<generated>)
 at net.sf.cglib.reflect.FastMethod.invoke(FastMethod.java:53)
 at org.apache.geronimo.gbean.runtime.FastMethodInvoker.invoke(FastMethodInvoker.java:38)
 at org.apache.geronimo.gbean.runtime.GBeanOperation.invoke(GBeanOperation.java:122)
 at org.apache.geronimo.gbean.runtime.GBeanInstance.invoke(GBeanInstance.java:817)
 at org.apache.geronimo.gbean.runtime.RawInvoker.invoke(RawInvoker.java:57)
 at org.apache.geronimo.kernel.basic.RawOperationInvoker.invoke(RawOperationInvoker.java:35)
 at org.apache.geronimo.kernel.basic.ProxyMethodInterceptor.intercept(ProxyMethodInterceptor.java:96)
 at org.activeio.xnet.ServerService$$EnhancerByCGLIB$$860a25cd.service(<generated>)
 at org.activeio.xnet.ServicePool$2.run(ServicePool.java:67)
 at org.activeio.xnet.ServicePool$3.run(ServicePool.java:90)
 at org.apache.geronimo.pool.ThreadPool$1.run(ThreadPool.java:172)
 at org.apache.geronimo.pool.ThreadPool$ContextClassLoaderRunnable.run(ThreadPool.java:289)
 at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Thread.java:595)

I assume that the error is from the insert statement but I did not find any examples to work with. Please help ...

Re: CMP EJB with identity primary key

Posted by Radu Dumitrescu <rd...@pss.ro>.
I fixed it - the insert statement must be INSERT INTO APP.PRODUCTS (NAME, DESCRIPTION, PRICE) VALUES (null, null, null) - seems pretty strange...