Solved

Hibernate Update query from multiple tables.

Posted on 2010-08-22
4
1,093 Views
Last Modified: 2013-11-11
I have the following sql Query which works perfectly fine. How do I write the same in Hibernate. I would be happy if you could give an example for three tables Ex: A, B and C where update a.name set a.name="myname" where A.col1=B.col3 and B.col2=C.col1 and a.age ='20'




UPDATE (select P.cart_item as New_Cart_Item , C.cart_item as Old_Cart_Item
                 from prices P, carts C
                 where P.cart_item = C.cart_item
                     and BLAH BLAH BLAH )
    set Old_Cart_Item = New_Cart_Item
0
Comment
Question by:prsubject
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 33498663
You means in HQL ?
0
 
LVL 20

Accepted Solution

by:
Sathish David  Kumar N earned 500 total points
ID: 33498693
0
 
LVL 10

Expert Comment

by:Hegemon
ID: 33499068
With Hibernate you don't construct HQL queries to update objects. You call (for example) yourObject.saveOrUpdate() and the yourObject with all related objects get persisted.

However, it is perfectly fin to run a usual SQL update like in your example of you want to make changes directly in the database.
0
 
LVL 20

Assisted Solution

by:Sathish David Kumar N
Sathish David  Kumar N earned 500 total points
ID: 33499163
this saveOrUpdate() is used for DAOTemplates if you use sessionFactory object means
u can manly writer the query
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stringclean challenge 26 78
word0 challenge 4 72
sites similar to codingbat to improve coding hanson skills 3 66
Glassfish admin console not working 1 60
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question