Hibernate database level lock
i don't understand how to check the lock on database rows.
i got a postgresql server which a java desktop aaplication is requesting.
let's suppose a part of my code is like this :
Person p = mySession.getCurrentSession().load (Person.class, 5, LockMode.UPGRADE);
this work perfectly the person of id 5 is loaded and an upgrade lock is created, i can see it as if another thread of the same instance use the getCurrentLockMode function (on an object for the same db record using the get function)
My problem appears when another instance ask the same data. I dunno how to check if it's in used.
This other instance clearly know the data is locked as it will standby on the Person p = mySession.getCurrentSession().load (Person.class, 5, LockMode.UPGRADE); line, until the first instance remove its lock.
i would like to be able to check instead of just waiting, there i can tell the user "one of your colleague is currently editing this data, please try again later".
Thanks for any tips :)