Example usage for org.springframework.dao.support DataAccessUtils uniqueResult

List of usage examples for org.springframework.dao.support DataAccessUtils uniqueResult

Introduction

In this page you can find the example usage for org.springframework.dao.support DataAccessUtils uniqueResult.

Prototype

@Nullable
public static <T> T uniqueResult(@Nullable Collection<T> results)
        throws IncorrectResultSizeDataAccessException 

Source Link

Document

Return a unique result object from the given Collection.

Usage

From source file:pe.gob.mef.gescon.hibernate.impl.UserDaoImpl.java

@Override
public Mtuser getMtuserByEmail(String email) throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtuser.class);
    criteria.add(Restrictions.eq("vcorreo", email));
    return (Mtuser) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

From source file:de.forsthaus.backend.dao.impl.OrderDAOImpl.java

@SuppressWarnings("unchecked")
@Override// w  w  w . j  a va2  s  .  com
public BigDecimal getOrderSum(Order order) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Orderposition.class);
    criteria.add(Restrictions.eq("order", order));
    criteria.setProjection(Projections.sum("aupGesamtwert"));

    BigDecimal sumResult = (BigDecimal) DataAccessUtils
            .uniqueResult(getHibernateTemplate().findByCriteria(criteria));

    return sumResult;
}

From source file:no.dusken.aranea.service.PersonServiceImpl.java

/**
 * Gets a person byuser name/*from  ww  w. ja  v a 2s .co  m*/
 * 
 * @param username
 *            the name to get
 * @return a person if found, null if not
 */
public Person getPersonByUsername(String username) {
    if (username == null || username.equals("")) {
        return null;
    }
    Person p = null;
    try {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("username", username.toLowerCase());
        List<Person> list = genericDao.getByNamedQuery("person_byusername", map);
        p = (Person) DataAccessUtils.uniqueResult(list);
    } catch (DataAccessException dae) {
        log.warn("Unable to get Person", dae);
    }
    return p;
}

From source file:no.dusken.aranea.service.ImageServiceImpl.java

public Image getImageFileByHash(String hash) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("hash", hash);
    try {/* w ww.  jav  a2s  .c  o  m*/
        List<Image> list = genericDao.getByNamedQuery("image_byhash", map);
        return DataAccessUtils.uniqueResult(list);
    } catch (DataAccessException dae) {
        log.warn("Unable to get images", dae);
    }
    return null;
}

From source file:pe.gob.mef.gescon.hibernate.impl.UserDaoImpl.java

@Override
public Mtuser getMtuserByLogin(String login) throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtuser.class);
    criteria.add(Restrictions.eq("vlogin", login));
    return (Mtuser) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

From source file:pe.gob.mef.gescon.hibernate.impl.ConocimientoDaoImpl.java

@Override
public Tconocimiento getTconocimientoById(BigDecimal id) throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Tconocimiento.class);
    criteria.add(Restrictions.eq("nconocimientoid", id));
    return (Tconocimiento) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

From source file:no.dusken.aranea.service.IssueServiceImpl.java

public Issue getOldestIssue() {
    Issue i = null;/*from www.  j  ava  2  s  .  c om*/
    try {
        List<Issue> list = genericDao.getByNamedQuery("issues_oldest", null);
        Object o = DataAccessUtils.uniqueResult(list);
        if (o != null && o instanceof Issue) {
            i = (Issue) o;
        }
    } catch (DataAccessException dae) {
        log.warn("Unable to get Issue", dae);
    }
    return i;
}

From source file:fr.gael.dhus.database.dao.ProductDao.java

/**
 * Does the product corresponding to the given url exist in the database ?
 * Processed or not./*from w  w  w  .ja va 2 s  .  co  m*/
 */
public boolean exists(URL url) {
    if (url == null)
        return false;

    Product p = (Product) DataAccessUtils
            .uniqueResult(getHibernateTemplate().find("from Product where path=?", url));

    return p != null;
}

From source file:pe.gob.mef.gescon.hibernate.impl.UserDaoImpl.java

@Override
public Mtuser getMtuserById(BigDecimal nusuarioid) throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(Mtuser.class);
    criteria.add(Restrictions.eq("nusuarioid", nusuarioid));
    return (Mtuser) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

From source file:com.apress.progwt.server.dao.hibernate.UserDAOHibernateImpl.java

public User getForPaypalID(String paypalID) {
    return (User) DataAccessUtils.uniqueResult(
            getHibernateTemplate().findByNamedParam("from User where paypalId = :id", "id", paypalID));
}