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'm attaching a test case whit the 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.
I think this issue could be related with https://hibernate.atlassian.net/browse/HHH-6375.
Best regards. Hernán.