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