-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: UPDATE statement not supported?
PostPosted: Wed Jun 28, 2006 5:32 pm 
Newbie

Joined: Wed Jun 28, 2006 5:30 pm
Posts: 2
there are parent/child tables in the persist level of my app.

I am trying to use EJBQL to update the child table, link one row to the parent

something like this:

q = em.createQuery("update child c set c.parent = :PAR where c.id=1");
q.setParameter("PAR", parent);

here parent is a exsisting detached parent instance.

I got "DML not supported" error. anyone can help me? I am really a SQL beginer.

thanks a lot.

using EJB3.0 and MS SQL 2k


Last edited by jetzzz on Thu Jun 29, 2006 12:28 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 7:17 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
What version of Hibernate are you using? Looks like you're using the classic HQL parser, which doesn't support updates. Assuming that you're using hibernate 3, you'll have a line like this in your .cfg.xml file:
Code:
  <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
Delete it, and you'll revert to the default AST parser, which does handle updates.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 12:26 pm 
Newbie

Joined: Wed Jun 28, 2006 5:30 pm
Posts: 2
thanks for your response.

it's hibernate 3.1.2


my current Query translator is : org.hibernate.hql.ast.ASTQueryTranslatorFactory

and I am using jboss 4.0.4RC1 with EJB3 support.

did a further test, seems any UPDATE statement is not supported here,

here is stack trace:

javax.ejb.EJBException: org.hibernate.HibernateException: Not supported for DML operations
org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:192)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:54)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:219)
org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:55)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:102)



I am sure it's just a simple config problem, plz help, thanks a ton


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 29, 2006 7:33 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Odd. Are you using q.executeUpdate()? You can't use list() or uniqueResult() to execute updates, only executeUpdate.

_________________
Code tags are your friend. Know them and use them.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.