List of usage examples for javax.persistence OptimisticLockException OptimisticLockException
public OptimisticLockException(String message, Throwable cause, Object entity)
OptimisticLockException
exception with the specified detail message, cause, and entity. From source file:de.micromata.genome.jpa.Emgr.java
@Override public void deleteDetached(DbRecord<?> rec, boolean overwrite) throws OptimisticLockException { DbRecord<?> dbrec = selectByPkAttached(rec.getClass(), rec.getPk()); if (overwrite == false && rec instanceof StdRecord && dbrec instanceof StdRecord) { Integer thisupc = ((StdRecord<?>) rec).getUpdateCounter(); Integer dbupc = ((StdRecord<?>) dbrec).getUpdateCounter(); if (Objects.equals(thisupc, dbupc) == false) { throw new OptimisticLockException("Cannot delete " + dbrec.getClass().getName() + "(" + dbrec.getPk() + ") because version conflict: " + " old updatecounter: " + thisupc + "; new updatecounter: " + dbupc, null, dbrec); }/* w w w . j ava 2s . c o m*/ } deleteAttached(dbrec); }