[jboss-user] [EJB 3.0] - [JDBCExceptionReporter]'last_insert_id' is not a recognized
shipra
do-not-reply at jboss.com
Mon Jun 11 07:25:04 EDT 2007
Hi
I have been trying to connect to a DB on sql server using EJB3.0. I'm able to retrieve the data from the tables but cannot insert.
The tables are 'Address' and 'Person'.
The Unique auto generated 'id' of 'Address' table has to be inserted in the 'AddressId' field of Person.
Besides other fields, my EntityBean Person contains:
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name="addressId",
referencedColumnName="id")
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
....
Besides other fields, Address Entity Bean contains
@Id
@GeneratedValue
public int getId() {
return id;
}
Now while I'm trying to insert a new Record, I'm getting the following Exception:
[Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]'last_insert_id' is not a recognized function name.
14:30:58,108 ERROR [STDERR] javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not retrieve generated id after insert: [com.j3ltd.server.entities.Address]
14:30:58,108 ERROR [STDERR] at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
14:30:58,108 ERROR [STDERR] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
14:30:58,108 ERROR [STDERR] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
14:30:58,108 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:102)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:263)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:58)
14:30:58,124 ERROR [STDERR] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)
14:30:58,124 ERROR [STDERR] at $Proxy85.createPerson(Unknown Source)
14:30:58,124 ERROR [STDERR] at com.j3ltd.web.Register.register(Register.java:92)
.
.
.
.
.
and
.
.
.
.
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not retrieve generated id after insert: [com.j3ltd.server.entities.Address]
14:30:58,124 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:629)
14:30:58,124 ERROR [STDERR] at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:218)
14:30:58,124 ERROR [STDERR] at org.jboss.ejb3.entity.TransactionScopedEntityManager.persist(TransactionScopedEntityManager.java:175)
14:30:58,124 ERROR [STDERR] at com.j3ltd.server.session.EntityFacadeBean.createPerson(EntityFacadeBean.java:53)
14:30:58,124 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
14:30:58,124 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
14:30:58,124 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
14:30:58,124 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
Please could anyone help me out in solving this problem
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053041#4053041
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053041
More information about the jboss-user
mailing list