私は次のことを行います:
def currentUser = springSecurityService.currentUser
currentUser.name = "test"
currentUser.save(flush: true)
// some other code
currentUser.gender = "male"
currentUser.save(flush: true) // Exception occurs
これは私が得る例外です:
ERROR events.PatchedDefaultFlushEventListener - Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)
このエラーを防ぐにはどうすればよいですか? そのための最善の解決策は何ですか?
私はさまざまなアプローチを見つけました:
どちらを使用する必要がありますか?