Setting offset of zero has unexpected behaviour with fetch joins

Description

It is already known that FETCH joins and paging / limits do not play nicely together:

See org.hibernate.hql.internal.ast.QueryTranslatorImpl#list

The following test-case demonstrates the problem

The second assertion fails since the size is actually coming back as "1". By adding "setFirstResults(0)" to a query I would expect no impact in the final result. Is this assumption correct?

The incorrect logic seems to be in org.hibernate.engine.spi.RowSelection#definesLimits where it should read

The "firstRow" value should never be less than zero (enforced by the setter) so actually the problem only arises when the value of "firstRow" is precisely zero.

Environment

None

Assignee

Unassigned

Reporter

Marc Howarth

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure