setMaxResult(0) should return an empty List

Description

right now when we use setMaxResult(0), hibernate return all elements, as the sql instruction "limit" is not used.
We have this direct problem when we use a pagination and setMaxResult is can be set at 0.

That is link to "AbstractQueryImpl" and "LimitHelper".

the workaround is if "limit 0" is SQL correct we should accept it
if it isn't we should throw an exception.
But in any case we should create a request that return everything.

https://github.com/alexisgayte/hibernate-test-case-maxResult-0

Environment

sql, H2 all of them.

Status

Assignee

Andrea Boriero

Reporter

alexis gayte

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

4.3.11

Priority

Major
Configure