matrei commented on PR #16344:
URL: https://github.com/apache/grails-core/pull/16344#issuecomment-5682648035

   @jdaugherty What about `refreshWithLock`?
   
   Reasons it fits better than `lockLatest`:
   
   - It names the operation, not a promise. The method is literally Hibernate's 
`refresh(entity, PESSIMISTIC_WRITE)`. "Latest" claims something about the data 
that the docs then have to walk back. The reference page even contains the 
phrase "Despite its name, `lockLatest()` does not override isolation rules". A 
name that needs a disclaimer is the wrong name.
   - "Refresh" carries the important side effect. The most surprising thing 
about this method is that it discards unflushed edits. Every GORM user already 
knows `refresh()` does that. With `lockLatest` the docs need a WARNING block to 
say so. With `refreshWithLock` the name says it.
   - It matches what Hibernate and JPA users already know. 
`EntityManager.refresh(entity, LockModeType)` is the JPA spelling of the same 
thing, so the mapping is obvious.
   - It groups naturally with the existing API. `refresh()` and 
`refreshWithLock()` sit next to each other in completion and in the reference 
docs, and `lock()` stays the one method that locks without touching state. 
`lockLatest` instead reads like a variant of `lock()`, which invites the 
misunderstanding that it preserves pending edits the way `lock()` does.


-- 
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]

Reply via email to