Solved

Hibernate Update query from multiple tables.

Posted on 2010-08-22
4
1,087 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
  • 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

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 76
netstat -ano | find "8000" and taskkill /f /pid 2984 3 83
replace a word with other 1 45
collection output issue 9 36
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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.

809 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