[EJB 3.0] - [JDBCExceptionReporter]'last_insert_id' is not a recognized
by shipra
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
18Â years, 10Â months
[JBossWS] - Re: ant task produces java.lang.NoClassDefFoundError: com/s
by teknokrat
The relevant build.xml fragment is
| <path id="class.path">
| <fileset dir=".">
| <include name="jbossws-client.jar"/>
| <include name="getopt.jar"/>
| <include name="jbossws-wsconsume-impl.jar"/>
| <include name="jaxb-xjc.jar"/>
| <include name="jaxb-impl.jar"/>
| </fileset>
| </path>
|
| <target name="wsgenerate" description="">
| <taskdef
| name="wsconsume"
| classname="org.jboss.ws.tools.jaxws.ant.wsconsume"
| classpathref="class.path"
| />
| <wsconsume
| fork="true"
| verbose="true"
| destdir="bin"
| sourcedestdir="src"
| keep="true"
| wsdllocation="META-INF/wsdl/MyService.wsdl"
| wsdl="MyService.wsdl"
| package="my.ws">
| <binding dir="." includes="bindings.xml"/>
| </wsconsume>
| </target>
|
When I add tools.jar to the classpath, this works OK. But why can't it find tools.jar anyway as its being executed by the jvm anyway?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053036#4053036
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053036
18Â years, 10Â months
[JBoss AOP] - Re: How to avoid intercepting recursive calls
by kabir.khanï¼ jboss.com
1) Incorrect
| <aop>
| <cflow-stack name="NotRecursivePOJO">
| <not-called expr="* POJO->prepare(..)"/>
| </cflow-stack>
|
| <bind pointcut="execution(public * POJO->prepare(..))" cflow="NotRecursivePOJO">
| <interceptor class="Blah"/>
| </bind>
| </aop>
|
Will allow the method to be called. The not-called part makes sure it has not been called *previously*. Take a look at the "cflow" tutorial that comes with the dist.
2) I updated our tests and you can use wildcards so the following is valid
| <aop>
| <cflow-stack name="NotRecursivePOJO">
| <not-called expr="* org.blah.POJO->*(..)"/>
| </cflow-stack>
|
| <bind pointcut="execution(public * org.blah.POJO->*(..))" cflow="NotRecursivePOJO">
| <interceptor class="Blah"/>
| </bind>
| </aop>
|
You can also do more advanced things with the classname such as
| <aop>
| <cflow-stack name="NotRecursivePOJO">
| <not-called expr="* @org.blah.SomeAnnotation->*(..)"/>
| <not-called expr="* $instanceof(org.blah.Base}->get*(..)"/>
| <not-called expr="* $typedef(someDef}->*(..)"/>
| <not-called expr="* org.blah.Value*->*(..)"/>
| </cflow-stack>
|
Note that the access specifiers, return type and parameters are not used during the matching stage since this info is not avialble in StackTraceElement, all we have are the class and the method name.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/StackTraceElement.html
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4053028#4053028
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4053028
18Â years, 10Â months