I am using MySQL to store an EJB and after inserting a new instance of the class into the database I get the following:
javax.ejb.CreateException: Primary key for created instance is null. org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:574) org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:222) org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:266) org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:766) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.jboss.invocation.Invocation.performCall(Invocation.java:345) org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1113) org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90) org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:192) org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:212) org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:90) org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:117) org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:61) org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:28) org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:41) org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:109) org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335) org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:146) org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:116) org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:121) org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:93) org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:508) org.jboss.ejb.Container.invoke(Container.java:894) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:585) org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141) org.jboss.mx.server.Invocation.dispatch(Invocation.java:80) org.jboss.mx.server.Invocation.invoke(Invocation.java:72) org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249) org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644) org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155) org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104) org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:179) org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:165) org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46) org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55) org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:169) org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86) I had seen this problem solved on other posts by the use of mysql-get-generated-keys as the entity command, but in my case it does not seem to be helping. I have tried numerous variants of the entity-command and unknown-pk tags in jbosscmp-jdbc.xml. Here is a snippet from the relevant portion of my current jbosscmp-jdbc.xml file: <ejb-name>Subject</ejb-name> <table-name>Subject</table-name> <cmp-field> <field-name>id</field-name> <column-name>id</column-name> </cmp-field> <cmp-field> <field-name>name</field-name> <column-name>name</column-name> </cmp-field> <cmp-field> <field-name>description</field-name> <column-name>description</column-name> </cmp-field> <unknown-pk> <unknown-pk-class>java.lang.Long</unknown-pk-class> <auto-increment/> </unknown-pk> <entity-command name="mysql-get-generated-keys"> </entity-command> Can anyone offer suggestions on what else I can try? Thanks! View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3883471#3883471 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3883471 ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
