-->
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.  [ 7 posts ] 
Author Message
 Post subject: how to delete many record at once in hibernate?
PostPosted: Tue Jun 15, 2004 11:08 pm 
Newbie

Joined: Tue Feb 03, 2004 3:03 am
Posts: 12
using the session.delete, can delete one object,but we often want to delete many records and the delete condition may be not the id,but others,how to realize it in hibernate?
thk!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 3:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
session.delete(query)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 4:07 am 
Pro
Pro

Joined: Wed Oct 08, 2003 10:31 am
Posts: 247
michael wrote:
session.delete(query)


Does session.delete(query) internally load all objects before delete like doing "session.get(obj) ... session.delete(obj)" for all objects or does it do a direct "delete from xpto where ..."?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 6:59 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Yes, this is necessary because of things like cascade deltes, lifecycle interfaces, etc.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 10:08 am 
Newbie

Joined: Tue Feb 03, 2004 3:03 am
Posts: 12
thks.
is there any solution about update ? if I want to update many redord , I must load the object,and save it one to another,is there other solution?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 10:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
this is how ORM works...

if you have performance problem on a particular massive update use case, consider coding it in JDBC but be carefull with hibernate session (1st level cache) state and cascade...

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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 10:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I made a little hack lately to make using direct JDBC a bit easier ... don't know it is a good idea though or if it just creates confusion. http://www.gloegl.de/26.html


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.