-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is there a way to delete by id?
PostPosted: Thu Feb 26, 2004 10:23 am 
Newbie

Joined: Tue Nov 11, 2003 10:42 am
Posts: 9
Is there a way to delete an entity by providing only an id? I have a use case where I need to delete many hibernate objects in bulk. All I have is the ids. Since I just want to delete them from persistent storage, I would like to avoid needing to load the object first.

My id is a composite key of three fields and it's composite because it's legacy. I don't believe I can come up with an efficient query to retrieve the objects because of the composite key. So that eliminates the delete method on Session using a query.

I was expecting to see some method like Session.delete(Serializable id) or Session.deleteById(Serializable id). Is something like that available or is there a better way to do what I want?

Hibernate 2.1.1

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 26, 2004 10:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
An OR-Mapper will allways have to load the objects first, because we have to check for cascades, lifecycle, etc. So just use session.delete(query) or use a direct JDBC connection.


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