Solved

Hibernate Update query from multiple tables.

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fetching the full url inside controller 2 42
factorial example challenge 10 103
strCopies  challenge 17 87
How to increase Spring boot/Tomcat max file upload size 2 59
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now