[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5771) PersistentBag.remove() and removeAll() load the whole collection
Mauricio Hiroshi Nagaoka (JIRA)
noreply at atlassian.com
Sat Jul 2 01:27:55 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=42748#action_42748 ]
Mauricio Hiroshi Nagaoka commented on HHH-5771:
-----------------------------------------------
I also came across this issue when trying to remove from a {{Bag}} mapped as {{cascade="all,delete-orphan"}}, even when specifying {{lazy="extra"}}.
Looking at the source code (Hibernate 3.5.1, in my case), it seems {{PersistentBag}} doesn't honor the "laziness" specified on the collection mapping like {{PersistentSet}} and {{PersistentList}} do.
@Dobes as a workaround, I would suggest you to use a {{<set cascade="all,delete-orphan" lazy="extra">}} instead. The shortcoming of this approach is that Hibernate needs to check for uniqueness when you add to the {{Set}}. This is done by issuing a {{select 1 from...}} so it may not be *that* expensive.
> PersistentBag.remove() and removeAll() load the whole collection
> ----------------------------------------------------------------
>
> Key: HHH-5771
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5771
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.5
> Reporter: Dobes Vandermeer
>
> When removing an entity from the database, it is a requirement in hibernate that you remove the entity from any persistent collections it is in so that you don't get errors about transient objects being referenced by a collection.
> However, calling remove() on a persistent collection seems to load the whole collection into memory.
> The use of very large (too big to load all at once) lazy collections is apparently not well supported in hibernate because it is difficult to use them without loading the whole collection into memory rather than load it incrementally. Nevertheless, it is possible to request subsets of collections and having the ability to remove() without loading the lazy collection would be a bonus for those of us who do use large lazy collections that way.
> Here is the offending code:
> {code}
> public boolean remove(Object o) {
> initialize( true );
> if ( bag.remove( o ) ) {
> dirty();
> return true;
> }
> else {
> return false;
> }
> }
> {/code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list