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 have 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 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> <auto-increment /> </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> <entity-command name="mysql-get-generated-keys" /> Any suggestions are grealy appreciated View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3884249#3884249 Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3884249 ------------------------------------------------------- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar _______________________________________________ JBoss-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jboss-user
