collection size() with lazy extra does not applies filters if proxy is not initialized

Description

Hi!

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.

Environment

None

Assignee

Unassigned

Reporter

Hernán Chanfreau

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

Affirmative

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure