@Transactional
  @TransactionalLock(lockArea = LockArea.HRC_STATUS_CACHE, lockType = LockType.WRITE)
  public void create(HostRoleCommandEntity entity) {
    EntityManager entityManager = entityManagerProvider.get();
    entityManager.persist(entity);

    invalidateHostRoleCommandStatusSummaryCache(entity);
  }
NB: You cannot rely on return value if batch write is enabled
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java