-->
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: When not to use filters on collections
PostPosted: Thu Apr 16, 2009 10:04 am 
Newbie

Joined: Thu Apr 16, 2009 9:39 am
Posts: 4
Hi,

consider this mapping:


Code:
class Thing {
...
@OneToMany(mappedBy = "thing", cascade = CascadeType.ALL)
@org.hibernate.annotations.Cascade(
value = org.hibernate.annotations.CascadeType.DELETE_ORPHAN
)
@Filters({
        @Filter(name = "littleThings", condition = "(littles = 0)"),
        @Filter(name = "specificThings", condition = "(specific in (:id))")
})
private Set<BigThing> bigThings= new HashSet<BigThing>();
...
}


Suppose an unfiltered collection contains thousand of littleThing and specificThing objects. A use case demands that the user sees only the littleThings so you enable the filter "little things".

The user adds some entries to the filtered list and pushes the "save" button. The new littleThings are persisted but because Hibernate does not see any specificThings in the filtered collection all specificThing objects are being removed!

So is filtering a collection only useful for "read-only" data??

Is there a way to circumvent this and still using filters?

Thx,
Squib


Top
 Profile  
 
 Post subject: Re: When not to use filters on collections
PostPosted: Mon May 04, 2009 1:45 pm 
Newbie

Joined: Tue Jul 03, 2007 1:46 pm
Posts: 2
you just have to make sure that you are enabling the (same) filter again while persisting the collection. that's it.


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.