Example usage for org.springframework.dao EmptyResultDataAccessException EmptyResultDataAccessException

List of usage examples for org.springframework.dao EmptyResultDataAccessException EmptyResultDataAccessException

Introduction

In this page you can find the example usage for org.springframework.dao EmptyResultDataAccessException EmptyResultDataAccessException.

Prototype

public EmptyResultDataAccessException(int expectedSize) 

Source Link

Document

Constructor for EmptyResultDataAccessException.

Usage

From source file:io.lavagna.service.ConfigurationRepository.java

public String getValue(Key key) {
    List<String> res = queries.getValue(key.toString());
    if (res.isEmpty()) {
        throw new EmptyResultDataAccessException(1);
    } else {/*from w w w.  j  a  v a  2s.  co m*/
        return res.get(0);
    }
}

From source file:org.socialsignin.roo.showcase.springsocial.jpa.RooJpaTemplate.java

@Override
public RemoteUser get(String userId, String providerId, String providerUserId) {
    UserConnection userConnection = rooTemplate.getUserConnection(userId, providerId, providerUserId);
    if (userConnection == null) {
        throw new EmptyResultDataAccessException(1);
    }// w  w w.j a v a2 s. c  o m

    return new RooRemoteUser(userConnection);
}

From source file:de.codesourcery.eve.skills.db.dao.HibernateDAO.java

protected static <T> T getExactlyOneResult(List<T> result) {
    if (result.isEmpty()) {
        throw new EmptyResultDataAccessException(1);
    }//from   w ww.ja  v a 2  s  . c  o m
    if (result.size() > 1) {
        throw new IncorrectResultSizeDataAccessException("Internal error, got more than I expected?", 1,
                result.size());
    }
    return result.get(0);
}

From source file:com.daugherty.e2c.persistence.data.jdbc.JdbcSupplierDao.java

@Override
public Supplier loadLatest(Long id, Locale locale) {
    LOGGER.debug("Looking up latest supplier with ID " + id);
    String sql = getSql("supplier/loadLatest.sql");
    SqlParameterSource parameterSource = new MapSqlParameterSource().addValue("partyId", id)
            .addValue(SqlQueryCriteria.LANGUAGE_PARAMETER_NAME, locale.getLanguage());
    Supplier supplier = null;//w  ww. j av  a  2s .  c  o m
    try {
        supplier = jdbcTemplate.query(sql, parameterSource, new SupplierResultSetExtractor()).get(0);
    } catch (IndexOutOfBoundsException e) {
        throw new EmptyResultDataAccessException(1);
    }

    return supplier;
}

From source file:com.daugherty.e2c.persistence.data.jdbc.JdbcSupplierDao.java

@Override
public Supplier loadApproved(Long id, Locale locale) {
    LOGGER.debug("Looking up approved supplier with ID " + id);
    String sql = getSql("supplier/loadApproved.sql");
    SqlParameterSource parameterSource = new MapSqlParameterSource().addValue("partyId", id)
            .addValue(SqlQueryCriteria.LANGUAGE_PARAMETER_NAME, locale.getLanguage());
    Supplier supplier = null;/*from w  ww.ja  va 2 s.  c o m*/
    try {
        supplier = jdbcTemplate.query(sql, parameterSource, new SupplierResultSetExtractor()).get(0);
    } catch (IndexOutOfBoundsException e) {
        throw new EmptyResultDataAccessException(1);
    }

    return supplier;
}

From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ParametreCommunalFichierTxtDao.java

public BigDecimal getPartPrivilegiee(int annee, int noOFSCommune) {
    BigDecimal part = mapPartPrivilegiee.get(new CleParametre(annee, noOFSCommune));
    if (null == part)
        throw new EmptyResultDataAccessException(1);
    return part;//from w  ww  .j  a  va  2 s  . c  o  m
}

From source file:org.impotch.calcul.impot.cantonal.ge.param.dao.ParametreCommunalFichierTxtDao.java

public BigDecimal getTauxCentimes(int annee, int noOFSCommune) {
    BigDecimal taux = mapCtsAdd.get(new CleParametre(annee, noOFSCommune));
    if (null == taux)
        throw new EmptyResultDataAccessException(1);
    return taux;//w  w  w . j a  v  a2  s . c  o  m
}

From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.entity.SecondaryEntityDAO.java

public Experiment getExperiment(final long experimentId) {
    final ExperimentProjectGroupCodeRecord record = query
            .getExperimentAndProjectAndGroupCodeForId(experimentId);
    if (record == null) {
        throw new EmptyResultDataAccessException(1);
    }/*from w  w  w  .  java  2 s.  c o  m*/
    return createExperiment(experimentId, record);
}

From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.common.entity.SecondaryEntityDAO.java

public Person getPerson(long personId) {
    Person registrator = query.getPersonById(personId);
    if (registrator == null) {
        throw new EmptyResultDataAccessException(1);
    }// w  ww .  j  av a 2 s .  c  o m
    registrator.setUserId(escapeHtml(registrator.getUserId()));
    registrator.setEmail(escapeHtml(registrator.getEmail()));
    registrator.setFirstName(escapeHtml(registrator.getFirstName()));
    registrator.setLastName(escapeHtml(registrator.getLastName()));
    return registrator;
}

From source file:org.cloudfoundry.identity.uaa.codestore.ExpiringCodeStoreTests.java

@Test(expected = EmptyResultDataAccessException.class)
public void testExpirationCleaner() throws Exception {
    if (JdbcExpiringCodeStore.class == expiringCodeStoreClass) {
        jdbcTemplate.update(JdbcExpiringCodeStore.insert, "test", System.currentTimeMillis() - 1000, "{}");
        ((JdbcExpiringCodeStore) expiringCodeStore).cleanExpiredEntries();
        jdbcTemplate.queryForObject(JdbcExpiringCodeStore.select,
                new JdbcExpiringCodeStore.JdbcExpiringCodeMapper(), "test");
    } else {//from www .  ja  va 2s  .co  m
        throw new EmptyResultDataAccessException(1);
    }

}