prsubject
asked on
Hibernate Update query from multiple tables.
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
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
You means in HQL ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.