-->
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: hibernate update problem
PostPosted: Thu Mar 22, 2007 9:10 pm 
Beginner
Beginner

Joined: Sat Mar 03, 2007 5:32 am
Posts: 20
i tried to update my record using customize HQL. but i have encounter some problem.

My code is as follow:

Code:
           
String sql="update Enquiry enq SET enq.threadStatus= :threadStatus where enq.id= :threadId";           
            Query query=session.createQuery(sql);
            query.setInteger("threadStatus",2);
            query.setInteger("threadId", Integer.parseInt(threadId));
            int result=query.executeUpate();


from my console my sql look like this:
update COLLAB_THREAD enquiry0_ set enquiry0_.THREAD_STATUS=? where (enquiry0_.ID=?)


my error is as follow:
Incorrect syntax near 'enquiry0_'.
org.hibernate.exception.SQLGrammarException: could not execute update query


please help. thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 23, 2007 8:03 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Did you try executing the query inside your favorite sql client to know which enquiry0_ is wrong? (Since it's present three times in the generated SQL).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 12:26 am 
Beginner
Beginner

Joined: Sat Mar 03, 2007 5:32 am
Posts: 20
but i though the enquiry_0, is just the alias to represent the table name.?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 25, 2007 7:37 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Yes, that's it. But, it seems like your dbms doesn't like this somewhere, so you should try and know which part of the query is rejected.

Maybe also, about this part of the query:
Quote:
Code:
            query.setInteger("threadId", Integer.parseInt(threadId));

Try and debug what Integer.parseInt() returns... I don't think this is the problem, but check it out anyway...

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.