According to https://javaee.github.io/javaee-spec/javadocs/javax/persistence/Query.html#setMaxResults-int-
{code:java} maxResult - maximum number of results to retrieve {code}
The documentation does not specify that maxResult must be >0. Also, previous Hibernate versions did not ignore maxResult == 0. The problem is that LimitHelper.hasMaxRows() ignores parameter completely (providing the whole result set) if it is == 0:
{code:java} public static boolean hasMaxRows(RowSelection selection) { return selection != null && selection.getMaxRows() != null && selection.getMaxRows() > 0; } public static boolean useLimit(LimitHandler limitHandler, RowSelection selection) { return limitHandler.supportsLimit() && hasMaxRows( selection ); } {code}
It breaks legacy behavior, so rather serious problem. |
|