My Requirement:
I am using Quartz cron
for triggering purpose, Many triggers are running on same row but base on different column. So when trigger need to update its related column. trigger first refresh(Session.refresh(object)
) the object belong to it(object is selected at starting of trigger) from database and then take an UPGRADE LOCK
at row level. if it is success on getting lock then is update column and use session.update(object)
to update in DB. and release the lock.
What is the alternative of session.refresh(Object, LockMode.UPGRADE)
and efficient way to avoid dirty update using hibernate ?
Why it is deprecated in hibernate ?
What is the alternative of
session.refresh(Object, LockMode.UPGRADE)
and efficient way to avoid dirty update using hibernate ?
Right there in the documentation:
Deprecated.
LockMode
parameter should be replaced withLockOptions
E.g., use refresh(Object,LockOptions)
.
It doesn't say why, but it's clear about what to do instead. (And there is a LockOptions.UPDATE
.)