JavaRanch » Java Forums »
Databases »
Object Relational Mapping
| Author |
Problem with Hql Update
|
Sujoy Mukherjee
Ranch Hand
Joined: Dec 31, 2005
Posts: 46
|
|
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: 46
|
|
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: 219
|
|
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: 219
|
|
Hey Emanuel,
Good catch..
The correct hql would be -
|
 |
Sujoy Mukherjee
Ranch Hand
Joined: Dec 31, 2005
Posts: 46
|
|
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: 46
|
|
Correction. it has been solved. i was using the table name instead of class name.
Thanks for your help.
|
 |
 |
|
|
subject: Problem with Hql Update
|
|
|
|