public static void releaseLock(EntityManager em,long type,String key){
  EntityTransaction tx=null;
  try {
    tx=em.getTransaction();
    tx.begin();
    GlobalInterlock lock=_findAndRefreshLock(em,type);
    if (lock == null) {
      throw new GlobalInterlockException("No lock of type " + type + " exists for key "+ key+ ".");
    }
    String ref=Long.toHexString(lock.lockTime);
    if (ref.equalsIgnoreCase(key)) {
      em.remove(lock);
      em.flush();
      tx.commit();
    }
 else {
      throw new GlobalInterlockException("This process doesn't own the type " + type + " lock having key "+ key+ ".");
    }
  }
  finally {
    if (tx != null && tx.isActive()) {
      tx.rollback();
    }
  }
}

public static void releaseLock ( EntityManager em , long type , String key ) { EntityTransaction tx = null ; try { tx = em . getTransaction ( ) ; tx . begin ( ) ; GlobalInterlock lock = _findAndRefreshLock ( em , type ) ; if ( lock == null ) { throw new GlobalInterlockException ( "No lock of type " + type + " exists for key " + key + "." ) ; } String ref = Long . toHexString ( lock . lockTime ) ; if ( ref . equalsIgnoreCase ( key ) ) { em . remove ( lock ) ; em . flush ( ) ; tx . commit ( ) ; } else { throw new GlobalInterlockException ( "This process doesn't own the type " + type + " lock having key " + key + "." ) ; } } finally { if ( tx != null && tx . isActive ( ) ) { tx . rollback ( ) ; } } }
releases a global lock of the indicated type if the supplied key is a match for the lock .
