tôi thực hiện như sau:StaleObjectStateException: Hàng đã được cập nhật hoặc xóa bởi một giao dịch khác?
def currentUser = springSecurityService.currentUser
currentUser.name = "test"
currentUser.save(flush: true)
// some other code
currentUser.gender = "male"
currentUser.save(flush: true) // Exception occurs
Đây là ngoại lệ tôi nhận được:
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)
Làm thế nào tôi có thể ngăn chặn lỗi này? Giải pháp tốt nhất cho điều đó là gì?
tôi thấy cách tiếp cận khác nhau:
Cái nào tôi nên sử dụng?
Bạn có thể viết lại mã của mình theo cách bạn nghĩ không? –
Vui lòng kiểm tra ngay bây giờ và cho tôi biết nếu bạn có bất kỳ mối lo ngại nào. Cảm ơn!!! –