docs: private boolean isOptimisticLockingException(DbOperation failedOperation, Throwable cause) {
  
      boolean isConstraintViolation = ExceptionUtil.checkForeignKeyConstraintViolation(cause);
      boolean isVariableIntegrityViolation = ExceptionUtil.checkVariableIntegrityViolation(cause);
  
      if (isVariableIntegrityViolation) {
  
        return true;
      } else if (
        isConstraintViolation
        && failedOperation instanceof DbEntityOperation
        && ((DbEntityOperation) failedOperation).getEntity() instanceof HasDbReferences
        && (failedOperation.getOperationType().equals(DbOperationType.INSERT)
        || failedOperation.getOperationType().equals(DbOperationType.UPDATE))
        ) {
  
        DbEntity entity = ((DbEntityOperation) failedOperation).getEntity();
        for (Map.Entry<String, Class> reference : ((HasDbReferences)entity).getReferencedEntitiesIdAndClass().entrySet()) {
          DbEntity referencedEntity = this.persistenceSession.selectById(reference.getValue(), reference.getKey());
          if (referencedEntity == null) {
  
            return true;
          }
        }
      }
  
      return false;
    }