[hibernate-dev] HHH-9789: collection size() with lazy extra does not applies filters if proxy is not initialized

Hernán Chanfreau hchanfreau at gmail.com
Tue Jun 9 09:19:23 EDT 2015


Hi!
A time ago I created this issue. The problem is this:

When using lazy extra and enabling filters affecting the collection, the
size() and isEmpty() methods are not applying the filters when the
collection proxy isn't initialized.

So, enabling filters and accessing a collection marked as lazy extra (the
filters applying to it), the methods size() and isEmpty() returns
differents values:

   - if the proxy is initialized, the methods access the real filtered
   collection.
   - if the proxy is not initialized, the methods fire a separated select
   count(*) ignoring the filters.

I´ve attached a test case.

I'm wondering if this scenario breaks the idea of not fetching the
collection if is not really needed (for lazy extra collections) or, we can
add on the fly the filters conditions to the select count(*) in order to
avoid fetching it.


What do you think?

Regards. Hernán.


More information about the hibernate-dev mailing list