This week's book giveaway is in the
We're giving away four copies of a choice of
"Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac"
and have Joe Kissell on-line!
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Take Control of Upgrading to Yosemite
Take Control of Automating Your Mac
this week in the
Object Relational Mapping
Writing Update query in Hibernate
Joined: Mar 13, 2006
Aug 10, 2006 03:47:00
I need to write the following
SQL using Hibernate.
SQL = "Update MT_PERSON set DELETE_IND = 'Y' where "
+"((ACTIVE_ID=? and LINKED_ID=?) or (ACTIVE_ID=? "
+"and LINKED_ID=?)) and LINKED_TY = 'U'";
Can someone please help by providing me with a step-by-step procedure on how to do so using Hibernate.
Thanks in Advance.
Joined: Feb 05, 2001
Aug 10, 2006 06:59:00
Well, I would suggest just using the SQL directly.
Change the "?" to use named bind variables, like :firstLinkedId
Then in your SQLQUery object set the parameters, then call executeQuery()?
I can't remember the exact method name, but an IDE will drop down with all the methods available to SQLQuery, and should be able to find the method.
Perfect World Programming, LLC
Two Laptop Bag
How to Ask Questions the Smart Way FAQ
Joined: Mar 13, 2006
Aug 10, 2006 18:38:00
Session.createSQLQuery(SQL) is not available in net.sf.hibernate.Session. I am using Hibernate version 2. Pleae advise how I could write the UPDATE query.
Thanks in advance.
Joined: Jan 14, 2002
Aug 10, 2006 18:48:00
Sorry, I cant provide you the step-to-step solution. But, can share my idea.
Other approach would be apart from what discussed above.
First you can load the persistance class using session.find()/load() using the condition
(ACTIVE_ID=? and LINKED_ID=?)
. And, the call the setter method and then session.saveOrUpdate.
subject: Writing Update query in Hibernate
Hibernate - update specific field with unique id
Hibernate keeps updating database.
How to update a single field in hibernate
Hibernate and Jdbc
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014