Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate:Problem in updaing data to the database

 
Midhun Sivasankaran
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Please help me on updating the data using Hibernate. I have done the following

String hql = "UPDATE Relation SET frID = frID+1 WHERE projectID = 108";
Query query = session.createQuery(hql);
int rowCount = query1.executeUpdate();

But I'm getting the following error:

query must begin with SELECT or FROM: UPDATE [UPDATE Relation SET frID = frID+1 WHERE projectID = 108]

Thanks,
Midhun
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason you are trying to do this update with HQL? It would be easier to use session.saveOrUpdate.

If you do need to do this with HQL you need to call executeUpdate not executeQuery.
 
Ankit Garg
Sheriff
Posts: 9577
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to me that he is using executeUpdate. Maybe this could help...
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. Well spotted
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic