jdaugherty commented on PR #16344: URL: https://github.com/apache/grails-core/pull/16344#issuecomment-5720571400
@matrei thanks, all three are in `ba8a179899`. **Finding 1.** `lockRow` now binds the unproxied target in the union branch. The concrete-entity lookup has already initialized the proxy there, so it costs nothing; the joined and single-table branches still bind the instance as before, so an uninitialized proxy stays uninitialized on those paths. Both specs gain your reproducer as a data-driven feature: a subclass row loaded as a root-typed proxy, initialized, then `Root.lock(id, refresh: true)`. It asserts the proxy the caller holds is returned and reloaded, `PESSIMISTIC_WRITE` is recorded, and a raw JDBC `FOR UPDATE` contender on the locked table is refused. It runs for the table-per-concrete-class pair (contender on the concrete table) and the joined-table pair (contender on the root table). The Hibernate 7 union row failed with the `HibernateSystemException` you quoted before the fix. **Finding 2.** The Hibernate 7 guide NOTE uses your wording, and the `lockRow` javadoc now says `lock()` has the union limit for every class in the hierarchy because it always locks through the root. **Finding 3.** `recordLockMode` sets the entry only when the requested mode is `greaterThan` the recorded one. Both specs gain a sequence feature with your three rows (`lock()` then `PESSIMISTIC_READ`, `refresh(lock: true)` then `PESSIMISTIC_READ`, `PESSIMISTIC_FORCE_INCREMENT` then `PESSIMISTIC_WRITE`) plus the upgrade case (`PESSIMISTIC_READ` then `PESSIMISTIC_WRITE`), each also asserting the state was reloaded. On Hibernate 5 the same sequences already hold because its refresh listener passes the held mode along when the request is weaker; the force-increment row there expects `LockMode.FORCE`, the legacy alias Hibernate 5 records, as the existing rows in that spec do. The cascade-parent contender helper is generalized to `rowLockGranted(Class, Long)` and the existing caller updated. **Runs** (`DO_NOT_CACHE_TESTS=1`, `--no-build-cache`): | Run | Result | |---|---| | `grails-data-hibernate7-core:test` (full, incl. `Hibernate7RefreshLockSpec` 85/85) | 3159 tests, 0 failures, 24 skipped | | `grails-data-hibernate5-core:test` (full, incl. `Hibernate5RefreshLockSpec` 83/83) | 914 tests, 0 failures, 33 skipped | | `codeStyle` on both modules | clean | Ready for another look. -- 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]
