These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Update of many objects
PostPosted: Wed Jun 23, 2004 8:24 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 5:03 am
Posts: 34
I'm trying to let Hibernate update multple objects, this could be done by the follow update query:

UPDATE `tablename` SET `amount` = `amount` * x WHERE ...;

What is the best way to this in Hirbernate. I know i can't use session.createSqlQuery(), that's only for selects.

Thanx in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 8:28 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
begin trans
first load all objects,
then update objects (setter)
last commit

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 8:43 am 
Beginner
Beginner

Joined: Wed Aug 27, 2003 5:03 am
Posts: 34
Yes this works indeed, it seems a little 'overkill' if i see the amount of source code. But that can also be my own fault (how i wrote it). Be i think i go for this method. Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 23, 2004 8:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
if it is massive update, you can also get jdbc connection and do it in pure jdbc to save performance but be extremelly carefull with the session state and cache

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.