Example usage for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException

List of usage examples for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException

Introduction

In this page you can find the example usage for org.springframework.orm ObjectRetrievalFailureException ObjectRetrievalFailureException.

Prototype

public ObjectRetrievalFailureException(String persistentClassName, Object identifier) 

Source Link

Document

Create a new ObjectRetrievalFailureException for the given object, with the default "not found" message.

Usage

From source file:com.branded.holdings.qpc.repository.jdbc.JdbcOwnerRepositoryImpl.java

/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 *///from   ww w. ja va  2 s  .c  om
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id", params,
                BeanPropertyRowMapper.newInstance(Owner.class));
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}

From source file:com.rambird.miles.repository.jdbc.JdbcOwnerRepositoryImpl.java

/**
 * Loads the {@link Owner} with the supplied <code>id</code>; also loads the {@link Pet Pets} and {@link Visit Visits}
 * for the corresponding owner, if not already loaded.
 *///from ww  w.j  av a 2s  . com
@Override
public Owner findById(int id) throws DataAccessException {
    Owner owner;
    try {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", id);
        owner = this.namedParameterJdbcTemplate.queryForObject(
                "SELECT id, first_name, last_name, address, city, telephone FROM owners WHERE id= :id", params,
                ParameterizedBeanPropertyRowMapper.newInstance(Owner.class));
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Owner.class, id);
    }
    loadPetsAndVisits(owner);
    return owner;
}

From source file:com.catt.mobile.repository.jdbc.JdbcAccountRepositoryImpl.java

@Override
public List<Account> listAccount() {
    List<Account> list;/*from   w w w.j av  a  2  s.  c  o m*/
    try {

        list = this.namedParameterJdbcTemplate.query("SELECT id, name,  address, telephone,email FROM account",
                ParameterizedBeanPropertyRowMapper.newInstance(Account.class));
    } catch (EmptyResultDataAccessException ex) {
        throw new ObjectRetrievalFailureException(Account.class, 1);
    }
    return list;
}

From source file:org.opennms.ng.dao.support.ResponseTimeResourceType.java

private File getInterfaceDirectory(final String ipAddr, final boolean verify) {
    final File response = new File(m_resourceDao.getRrdDirectory(verify),
            DefaultResourceDao.RESPONSE_DIRECTORY);

    final File intfDir = new File(response, ipAddr);
    if (verify && !intfDir.isDirectory()) {
        throw new ObjectRetrievalFailureException(File.class,
                "No interface directory exists for " + ipAddr + ": " + intfDir);
    }/*from w w w  .  jav a  2  s  .c  o m*/

    return intfDir;
}

From source file:corner.orm.hibernate.impl.EntityServiceImpl.java

@Override
public <T> T findUnique(Class<T> clazz, Object[] conditions) {
    Iterator<T> it = this.find(clazz, conditions, null);
    T result = null;/*from   w ww  .  j  a v a  2 s.  co  m*/
    if (it.hasNext()) {
        result = it.next();
    }
    if (it.hasNext()) {
        throw new ObjectRetrievalFailureException("?!,?.", null);
    }
    return result;
}

From source file:org.dlw.ai.blackboard.dao.hibernate.GenericDaoHibernate.java

/**
 * {@inheritDoc}/*from   w ww  .  ja  va  2 s.  c o m*/
 */
@SuppressWarnings("unchecked")
public T get(PK id) {
    T entity = (T) hibernateTemplate.get(this.persistentClass, id);

    if (entity == null) {
        log.warn("Uh oh, '" + this.persistentClass + "' object with id '" + id + "' not found...");
        throw new ObjectRetrievalFailureException(this.persistentClass, id);
    }

    return entity;
}

From source file:org.opennms.ng.dao.support.InterfaceSnmpResourceType.java

private File getParentResourceDirectory(String parentResource, boolean verify) {
    File snmp = new File(m_resourceDao.getRrdDirectory(verify), DefaultResourceDao.SNMP_DIRECTORY);

    File parent = new File(snmp, parentResource);
    if (verify && !parent.isDirectory()) {
        throw new ObjectRetrievalFailureException(File.class,
                "No parent resource directory exists for " + parentResource + ": " + parent);
    }//from  w ww. j  a v  a  2s .  c o m

    return parent;
}

From source file:org.opennms.ng.dao.support.NodeSnmpResourceType.java

/** {@inheritDoc} */
@Override/*from w w w. j av a  2s .com*/
public boolean isResourceTypeOnNodeSource(String nodeSource, int nodeId) {
    File nodeSnmpDir = new File(m_resourceDao.getRrdDirectory(), DefaultResourceDao.SNMP_DIRECTORY
            + File.separator + ResourceTypeUtils.getRelativeNodeSourceDirectory(nodeSource).toString());
    if (!nodeSnmpDir.isDirectory()) {
        throw new ObjectRetrievalFailureException(File.class,
                "No directory exists for nodeSource " + nodeSource);
    }
    return nodeSnmpDir.listFiles(RrdFileConstants.RRD_FILENAME_FILTER).length > 0;
}

From source file:org.opennms.ng.dao.support.GenericIndexResourceType.java

private File getResourceTypeDirectory(int nodeId, boolean verify) {
    File snmp = new File(m_resourceDao.getRrdDirectory(verify), DefaultResourceDao.SNMP_DIRECTORY);

    File node = new File(snmp, Integer.toString(nodeId));
    if (verify && !node.isDirectory()) {
        throw new ObjectRetrievalFailureException(File.class,
                "No node directory exists for node " + nodeId + ": " + node);
    }//  ww w  .  j a v a2 s  . c  om

    File generic = new File(node, getName());
    if (verify && !generic.isDirectory()) {
        throw new ObjectRetrievalFailureException(File.class,
                "No node directory exists for generic index " + getName() + ": " + generic);
    }

    return generic;
}

From source file:mx.edu.um.mateo.rh.dao.impl.CategoriaDaoHibernate.java

/**
 * @see mx.edu.um.mateo.rh.service.CategoriaManager#obtiene(java.lang.String) 
 *///from  w w w .  j a  v a2s  . c  om
@Override
public Categoria obtiene(final Long id) {
    Categoria categoria = (Categoria) currentSession().get(Categoria.class, id);
    if (categoria == null) {
        log.warn("uh oh, categoria with id '" + id + "' not found...");
        throw new ObjectRetrievalFailureException(Categoria.class, id);
    }

    return categoria;
}