@Override
 public long getCountByAnd(final String entityName, final Map<String, ?> fields) {
   try {
     final EntityCondition condition = new EntityFieldMap(fields, EntityOperator.AND);
     final GenericValue countGV =
         EntityUtil.getOnly(
             delegatorInterface.findByCondition(
                 entityName + "Count", condition, ImmutableList.of(COUNT_FIELD_NAME), null));
     return countGV.getLong(COUNT_FIELD_NAME);
   } catch (final GenericEntityException e) {
     throw new DataAccessException(e);
   }
 }
 /**
  * We need to make sure that we account for failed upgrades - the QA-EACJ migration showed that
  * the table may linger but the sequence ids go
  *
  * @param entityName
  * @param nextId
  * @throws GenericEntityException
  */
 private void setNextId(String entityName, Long nextId) throws GenericEntityException {
   final GenericDelegator delegator = getDelegator();
   // First ensure we have an entry in SequenecValueItem table
   delegator.getNextSeqId(entityName);
   // Now set it to nextId
   GenericValue sequenceItem =
       EntityUtil.getOnly(
           delegator.findByAnd("SequenceValueItem", ImmutableMap.of("seqName", entityName)));
   if (sequenceItem != null) {
     sequenceItem.set("seqId", nextId);
     sequenceItem.store();
     delegator.refreshSequencer();
   }
 }