PK Generation Error with pk-sql and Oracle
droed Oct 9, 2003 4:44 PMI want to use an oracle stored proc to generate primary key IDs.
My jbosscmp-jdbc.xml has
<ejb-name>TextComponent</ejb-name>
<create-table>false</create-table>
<table-name>text_components</table-name>
<cmp-field>
<field-name>id</field-name>
<column-name>text_Component_id</column-name>
<auto-increment/>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>descr</column-name>
</cmp-field>
<cmp-field>
<field-name>textComponentData</field-name>
<column-name>component_text</column-name>
<jdbc-type>CLOB</jdbc-type>
<sql-type>CLOB</sql-type>
</cmp-field>
<entity-command name="pk-sql">
select pb_object.get_global_id from dual
</entity-command>
but during entity creation I get
2003-10-09 15:06:47,851 DEBUG [] findByPrimaryKey:execute- Executing SQL: SELECT text_Component_id FROM TEXT_COMPONENTS WHERE text_Component_id=?
2003-10-09 15:06:47,851 DEBUG [] findByPrimaryKey:execute- Executing SQL: SELECT text_component_type_id FROM TEXT_COMPONENT_TYPES WHERE text_component_type_id=?
2003-10-09 15:06:47,867 DEBUG [] TextComponent:fetchNextPrimaryKey- Executing SQL: select pb_object.get_global_id from dual
2003-10-09 15:06:47,882 DEBUG [] TextComponent:execute- Create: pk=39219551
2003-10-09 15:06:47,882 DEBUG [] TextComponent:entityExists- Executing SQL: SELECT COUNT(*) FROM TEXT_COMPONENTS WHERE text_Component_id=?
2003-10-09 15:06:47,898 ERROR [] TextComponent:entityExists- Error checking if entity exists
javax.ejb.EJBException: Internal error getting primary key field member id; CausedByException is:
null
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.getPrimaryKeyValue(JDBCAbstractCMPFieldBridge.java:207)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.setPrimaryKeyParameters(JDBCAbstractCMPFieldBridge.java:288)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCEntityBridge.setPrimaryKeyParameters(JDBCEntityBridge.java:642)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCCreateEntityCommand.entityExists(JDBCCreateEntityCommand.java:233)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCPkSqlCreateCommand.execute(JDBCPkSqlCreateCommand.java:75)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:569)
at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:225)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:270)
at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:571)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:998)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:188)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:215)
at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:88)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:91)
at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61)
at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28)
at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:88)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:243)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:74)
at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:92)
at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:120)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93)
at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:477)
at org.jboss.ejb.Container.invoke(Container.java:694)
at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invokeHome(BaseLocalProxyFactory.java:272)
at org.jboss.ejb.plugins.local.LocalHomeProxy.invoke(LocalHomeProxy.java:110)
at $Proxy49.create(Unknown Source)
I can see that the SQL is returning a new ID, maybe it's getting a SQLException when it tries to submit "SELECT COUNT(*) FROM TEXT_COMPONENTS WHERE text_Component_id=?" in JDBCInsertPKCreateCommand.beforeInsert() ? But if that were the case the Exception wouldn't be NULL...
If anyone has any ideas PLEASE let me know!
Thanks