We are trying to filter\manipulate Persistent Collection based upon the objects it contains (filter out specific entries).
Since this manipulation will be performed on a large number of different objects containing different collections it must be as generic as possible.
Filtering on HQL\SQL level is not an option since it will be impossible to maintain. This means it must be performed after the collection was loaded and initialized.
We are currently using many of the Hibernate Events to handle single objects,
so we tried listening on the InitializeCollectionEvent
.
But as it turns out, most of our collections are initialized using HQL Fetch so this event won't be raised for them.
Is there any other Hibernate Event that we can use?
Any other place where the Collections are processed after they are loaded?
We are using Hibernate 4.1.7 .
I think it's not a good idea to filter collection on server side, when the collection was loaded. If you do that it means smth goes wrong, rethink you db model or entity structure. One of the best way to filter collection - use HQL. Or you can either use @Where or @Loader, @Filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With