title: How can I lock a record across multiple instance of a program using hibernate and postrgresql?
body: <p>I would like to find a way to lock a record from instance A making so that instance B can <em>know</em> that the record is locked.</p>
  
  <p>Here is how the GUI is working :</p>
  
  <p>On instance A the user ask for modification of entity E. The program <em>check</em> something (try to reserve a token ? something else ? ...) and show a <em>modification dialog</em> if E is free.</p>
  
  <p>Lets say that instance A was able to <em>reserve</em> E, and instance B wants to open the same window. B try to lock the record (with yet to be found solution) and because A is already there, B is only displaying <em>consultation</em> dialog.</p>
  
  <p>I am using :</p>
  
  <ul>
  <li>java</li>
  <li>hibernate on each instance</li>
  <li>postgresql (maybe there is a lock behavior I can use ?)</li>
  </ul>
  
  <p>Note : I only want to lock 1 record of a table, not the entire table.</p>
  
  <p>Can someone give me a hint on what to use and maybe tell me also how I can manage an unlock protection if instance A crash ?</p>
  
  <p>Thanks in advance.</p>