borinquenkid opened a new issue, #16832:
URL: https://github.com/apache/grails-core/issues/16832
## Summary
On Hibernate 5, `deleteAll()` and `updateAll()` on a `DetachedCriteria`
ignore `max` and `offset` and write to every row the criteria matches. A bulk
write is one HQL statement with no `LIMIT`, so the caller's limit is dropped
without any error.
## Reproduce
Rows `a` (qty 1), `b` (qty 2), `c` (qty 3), `d` (qty null), in
`grails-test-examples/hibernate5/grails-hibernate`:
```groovy
ScenarioItem.where { qty > 0 }.max(1).deleteAll()
// returns 3, deletes a, b and c
ScenarioItem.where { qty > 0 }.offset(1).deleteAll()
// returns 3, deletes a, b and c
ScenarioItem.where { qty > 0 }.max(1).updateAll(status: ScenarioStatus.DONE)
// updates all 4 rows
```
## Expected
The call should not write to rows the caller excluded. Hibernate 7 on 8.0.x
(#16822) throws `InvalidDataAccessResourceUsageException` naming the value
(`deleteAll() cannot limit the rows it writes to, so it does not support
max(1); remove it or select the ids first`) and writes nothing.
## Proposal
Apply the same guard in the Hibernate 5 `deleteAll`/`updateAll` path so both
modules behave the same. This is a behaviour change on H5 for callers who
relied on the limit being ignored, so it needs a note in the upgrade guide.
Found while adding the shared H5/H7 integration scenarios in #16822
(`BulkWriteGuardScenarioSpec` is H7-only because of this).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]