Hi, I tried the @GeneratedValue(strategy=GenerationType.AUTO) annotation on an 
entity mapped to a table with auto pk on and it worked fine. Then I tried to 
use the @TableGenerator as follows:


  | @javax.persistence.Id()
  |     @javax.persistence.Column(name = "ID")
  |     @TableGenerator(name="Employee_Sequence", 
  |                                     table="ID_GEN",
  |                                     pkColumnName="GEN_NAME",
  |                                     pkColumnValue="GEN_VAL")
  |     @GeneratedValue(generator="Employee_Sequence")
  |     public int getId() {
  |             return id;
  |     }
  | 

after creating a ID_GEN table, and have removed the auto increment option from 
the Employee table id. But when I ran the application I got the following 
exception: 
anonymous wrote : 
  | Exception in thread "main" javax.ejb.EJBException: 
javax.persistence.PersistenceException: org.hibernate.HibernateException: The 
database returned no natively generated identity value
  |     at 
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
  |     at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
  |     at 
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
  |     at 
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
  |     at 
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:225)
  |     at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:106)
  |     at 
org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
  |     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:828)
  |     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:681)
  |     at 
org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:358)
  |     at 
org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:398)
  |     at 
org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:239)
  | 

I take that the table mode of auto-creating primary keys doesn't work with my 
db. I'm using MySQL 4.1.7-NT

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3954907#3954907

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3954907

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to