@SuppressWarnings("unchecked") @Test(expected = NoResultException.class) public void testExecuteNoUniqueResult() { GetFieldFromTableByUniqueField<Integer, String> sut = new GetFieldFromTableByUniqueField("Person", "followingCount", "displayName"); sut.setEntityManager(getEntityManager()); sut.execute(0); }
@SuppressWarnings("unchecked") public ResultFieldType execute(final UniqueFieldType param) { List<ResultFieldType> results = getEntityManager().createQuery(queryString).setParameter("uniqueValue", param) .getResultList(); if (results.size() != 1) { throw new NoResultException("Expected 1 record from " + entityName + " with " + resultFieldName + ":" + uniqueFieldName + ", but found " + results.size()); } return results.get(0); }
GetFieldFromTableByUniqueField extends BaseDomainMapper implements
        DomainMapper<UniqueFieldType, ResultFieldType> { @SuppressWarnings("unchecked") public ResultFieldType execute(final UniqueFieldType param) { List<ResultFieldType> results = getEntityManager().createQuery(queryString).setParameter("uniqueValue", param) .getResultList(); if (results.size() != 1) { throw new NoResultException("Expected 1 record from " + entityName + " with " + resultFieldName + ":" + uniqueFieldName + ", but found " + results.size()); } return results.get(0); } }
GetFieldFromTableByUniqueField extends BaseDomainMapper implements
        DomainMapper<UniqueFieldType, ResultFieldType> { @SuppressWarnings("unchecked") public ResultFieldType execute(final UniqueFieldType param) { List<ResultFieldType> results = getEntityManager().createQuery(queryString).setParameter("uniqueValue", param) .getResultList(); if (results.size() != 1) { throw new NoResultException("Expected 1 record from " + entityName + " with " + resultFieldName + ":" + uniqueFieldName + ", but found " + results.size()); } return results.get(0); } GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName);  GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName, final String inExtraConditions); }
GetFieldFromTableByUniqueField extends BaseDomainMapper implements
        DomainMapper<UniqueFieldType, ResultFieldType> { @SuppressWarnings("unchecked") public ResultFieldType execute(final UniqueFieldType param) { List<ResultFieldType> results = getEntityManager().createQuery(queryString).setParameter("uniqueValue", param) .getResultList(); if (results.size() != 1) { throw new NoResultException("Expected 1 record from " + entityName + " with " + resultFieldName + ":" + uniqueFieldName + ", but found " + results.size()); } return results.get(0); } GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName);  GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName, final String inExtraConditions); @SuppressWarnings("unchecked") ResultFieldType execute(final UniqueFieldType param); }
GetFieldFromTableByUniqueField extends BaseDomainMapper implements
        DomainMapper<UniqueFieldType, ResultFieldType> { @SuppressWarnings("unchecked") public ResultFieldType execute(final UniqueFieldType param) { List<ResultFieldType> results = getEntityManager().createQuery(queryString).setParameter("uniqueValue", param) .getResultList(); if (results.size() != 1) { throw new NoResultException("Expected 1 record from " + entityName + " with " + resultFieldName + ":" + uniqueFieldName + ", but found " + results.size()); } return results.get(0); } GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName);  GetFieldFromTableByUniqueField(final String inEntityName, final String inUniqueFieldName,
            final String inResultFieldName, final String inExtraConditions); @SuppressWarnings("unchecked") ResultFieldType execute(final UniqueFieldType param);  }