Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hibernate Update query from multiple tables.

Posted on 2010-08-22
4
Medium Priority
?
1,125 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 2000 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 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …
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.

610 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