protected void entityConcurrentModificationCheck(
      AuditConfiguration auditConfiguration,
      Session session,
      Long loadAuditTransactionId,
      AuditObject auditObject) {
    AuditType auditType = null;
    String targetEntityId = null;

    if (auditObject instanceof EntityAuditObject) {
      // only check the entities - the components are
      // going to be check on field level check
      EntityAuditObject entityAuditObject = (EntityAuditObject) auditObject;
      auditType = entityAuditObject.getAuditType();
      targetEntityId = entityAuditObject.getTargetEntityId();
    } else {
      ComponentAuditObject component = (ComponentAuditObject) auditObject;
      AuditObject entity = component.getParentAuditObject();

      while (entity != null && entity instanceof ComponentAuditObject) {
        entity = ((ComponentAuditObject) entity).getParentAuditObject();
      }

      auditType = component.getAuditType();
      targetEntityId = ((EntityAuditObject) entity).getTargetEntityId();
    }

    Long latestEntityTransactionId =
        HibernateAudit.getLatestAuditTransactionIdByEntityAndAfterAuditTransactionId(
            session, auditType, targetEntityId, loadAuditTransactionId);
    if (latestEntityTransactionId != null
        && !latestEntityTransactionId.equals(loadAuditTransactionId)) {
      if (ConcurrentModificationBehavior.THROW_EXCEPTION.equals(
          auditConfiguration
              .getExtensionManager()
              .getConcurrentModificationProvider()
              .getCheckBehavior())) {
        if (session.getTransaction().isActive()) {
          session.getTransaction().rollback();
        }
        throw new ObjectConcurrentModificationException(
            auditType.getClassName(), auditType.getLabel(), targetEntityId);
      } else if (ConcurrentModificationBehavior.LOG.equals(
          auditConfiguration
              .getExtensionManager()
              .getConcurrentModificationProvider()
              .getCheckBehavior())) {
        if (log.isWarnEnabled()) {
          log.warn(
              "Concurrent modification detected: className="
                  + auditType.getClassName()
                  + ",label="
                  + auditType.getLabel()
                  + ",targetEntityId="
                  + targetEntityId);
        }
      }
    }
  }
 protected List<AuditTypeField> getModifiedAuditTypeFields(
     Session session,
     AuditEvent e,
     Long loadAuditTransactionId,
     List<AuditTypeField> fieldsToCheck) {
   List<AuditTypeField> modifiedAuditTypeFields =
       HibernateAudit.getModifiedAuditTypeFields(
           session, fieldsToCheck, e.getEntityId(), loadAuditTransactionId);
   return modifiedAuditTypeFields;
 }