File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Problem with Hql Update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Problem with Hql Update" Watch "Problem with Hql Update" New topic
Author

Problem with Hql Update

Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 51

hi,
I am very new to hibernate. I am trying my hands on HQL. I am trying Updating a table but facing a problem. I will try to explain it in as much detail I can.
First of all I am using netbeans 7.2, Oracle 10G express edition.

(1)The Table called book and its like this:


(2)hibernate.cfg.xml


(3)hibernate.reveng.xml


(4)book.hbm.xml


(5)The POJO class, book.java


(6)And finally, HQLUpdate.java, where the problem occurs
Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 51

When I am executing HQLUpdate.java, the following Exception message comes:
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: expecting EQ, found ':' near line 1, column 26 [update book set bookname :bname where bookid :bid]

The full output looks like this:


Can you please tell me where is the problem?
Thanks in advance.
Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

The problem is with HQL you are using. You are using below query -



while it should be as mentioned below (= operator is missing in your query) -


Kindly try it and let us know if you are still facing any issues

Regards
Salil Verma
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
I think the last post is still missing a "=", try this ...

Salil Vverma
Ranch Hand

Joined: Sep 06, 2009
Posts: 255

Hey Emanuel,

Good catch..
The correct hql would be -

Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 51

Extremely sorry for replying so late. Thanks to both Salil and Emanuel for replying.
I tried your solution....but an exception is thrown now.
it is saying....Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: book is not mapped [update book set bookname =:bname where bookid =:bid]
The run window says
Sujoy Mukherjee
Ranch Hand

Joined: Dec 31, 2005
Posts: 51

Correction. it has been solved. i was using the table name instead of class name.
Thanks for your help.
 
wood burning stoves
 
subject: Problem with Hql Update