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:net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountDao.java

@Override
public Account findAccount(final String accountId) {
    return (Account) DataAccessUtils.uniqueResult(getHibernateTemplate()
            .findByNamedQueryAndNamedParam("Account.findAccountByAccountId", "accountId", accountId));
}

From source file:net.chrisrichardson.bankingExample.domain.hibernate.HibernateAccountDao.java

@Override
public Account findAccountWithOverdraftPolicy(String accountId) {
    return (Account) DataAccessUtils.uniqueResult(getHibernateTemplate().findByNamedQueryAndNamedParam(
            "Account.findAccountByAccountIdWithOverdraftPolicy", "accountId", accountId));
}

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

public Banner getBannerByHash(String hash) {
    Banner banner = null;//from  w w  w  .  ja  va  2  s .c om
    try {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("hash", hash);
        banner = (Banner) DataAccessUtils.uniqueResult(genericDao.getByNamedQuery("banner_byhash", map));
    } catch (DataAccessException dae) {
        log.info("Unable to get banner", dae);
    }
    return banner;
}

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

public PageRelation getPageRelation(Page page1, Page page2) {
    PageRelation p = null;/*from   ww  w. j  a  va  2 s. c o  m*/
    try {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("p1", page1);
        map.put("p2", page2);
        List<PageRelation> list = genericDao.getByNamedQuery("getrelationsbypages", map);
        p = (PageRelation) DataAccessUtils.uniqueResult(list);
    } catch (DataAccessException dae) {
        log.warn("Unable to get getrelationsbypages", dae);
    }
    return p;
}

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

public Tag getTagByName(String name) {
    Tag t = null;//from w  w w. ja  va2  s.  c o m
    try {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("name", name);
        List<Tag> tags = genericDao.getByNamedQuery("tag_byname", map);
        t = (Tag) DataAccessUtils.uniqueResult(tags);
    } catch (DataAccessException dae) {
        log.info("Unable to get Tags", dae);
    }
    return t;
}

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

@SuppressWarnings("unchecked")
public Office getOfficeByFilNr(String fil_nr) {
    DetachedCriteria criteria = DetachedCriteria.forClass(Office.class);
    criteria.add(Restrictions.eq("filNr", fil_nr));

    return (Office) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

From source file:net.sf.sail.webapp.dao.user.impl.HibernateUserDao.java

/**
 * @see net.sf.sail.webapp.dao.user.UserDao#retrieveByUserDetails(org.acegisecurity.userdetails.UserDetails)
 */// w  w w. j  a v  a2s . c  om
public User retrieveByUserDetails(UserDetails userDetails) {
    return (User) DataAccessUtils.uniqueResult(this.getHibernateTemplate().findByNamedParam(
            "from UserImpl as user where user.userDetails = :userDetails", "userDetails", userDetails));
}

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

/**
 * cnishimura/*from   ww w. j  a v  a 2 s  . c o  m*/
 * @param ntpoconocimientoid
 * @return
 * @throws Exception 
 */
@Override
public MttipoConocimiento getMttipoConocimientoById(BigDecimal ntpoconocimientoid) throws Exception {
    DetachedCriteria criteria = DetachedCriteria.forClass(MttipoConocimiento.class);
    criteria.add(Restrictions.eq("ntpoconocimientoid", ntpoconocimientoid));
    return (MttipoConocimiento) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}

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

public Section getSectionByUrl(String sectionurl, Section parent) {
    Section s = null;/*from  w w  w  .j  av a  2  s  .co m*/
    try {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("sectionurl", sectionurl);
        List<Section> sections;
        if (parent != null) {
            map.put("parent", parent);
            sections = genericDao.getByNamedQuery("section_sectionsbyurlandparent", map);
        } else {
            sections = genericDao.getByNamedQuery("section_sectionsbyurl", map);
        }
        s = DataAccessUtils.uniqueResult(sections);

    } catch (DataAccessException dae) {
        log.info("Unable to get Sections", dae);
    }
    return s;

}

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

@SuppressWarnings("unchecked")
public SecUser getUserByFiluserNr(String usr_nr) {
    DetachedCriteria criteria = DetachedCriteria.forClass(SecUser.class);
    criteria.add(Restrictions.eq("usrNr", usr_nr));

    return (SecUser) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
}