Solved

Hibernate Update query from multiple tables.

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
seriesUp challenge 7 107
powerN  challenge 3 49
topping1 challenge 7 53
ArrayIndexOutOfBoundException 9 39
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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…
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.

747 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

14 Experts available now in Live!

Get 1:1 Help Now