List of usage examples for org.springframework.dao.support DataAccessUtils uniqueResult
@Nullable public static <T> T uniqueResult(@Nullable Collection<T> results) throws IncorrectResultSizeDataAccessException
From source file:com.apress.progwt.server.dao.hibernate.SchoolDAOHibernateImpl.java
public ProcessType getProcessForName(String string) { DetachedCriteria crit = DetachedCriteria.forClass(ProcessType.class).add(Expression.eq("name", string)); return (ProcessType) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(crit)); }
From source file:no.dusken.aranea.service.ImageServiceImpl.java
public Image getImageByHash(String hash) { // just to be safe: if (hash == null || hash.equalsIgnoreCase("")) { return null; }//from ww w.jav a 2s. c o m Image image = null; try { Map<String, Object> map = new HashMap<String, Object>(); map.put("hash", hash); image = (Image) DataAccessUtils.uniqueResult(genericDao.getByNamedQuery("image_byHash", map)); } catch (DataAccessException dae) { log.info("Unable to get images", dae); } return image; }
From source file:de.forsthaus.backend.dao.impl.CustomerDAOImpl.java
@SuppressWarnings("unchecked") public Customer getCustomerByKunNr(String kun_nr) { DetachedCriteria criteria = DetachedCriteria.forClass(Customer.class); criteria.add(Restrictions.eq("kunNr", kun_nr)); return (Customer) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria)); }
From source file:com.apress.progwt.server.dao.hibernate.SchoolDAOHibernateImpl.java
public School getSchoolFromName(String name) { return (School) DataAccessUtils.uniqueResult(getHibernateTemplate().find("from School where name=?", name)); }
From source file:fr.gael.dhus.database.dao.ProductDao.java
public Product getProductByPath(final URL path) { if (path == null) return null; Product p = (Product) DataAccessUtils .uniqueResult(getHibernateTemplate().find("from Product where path=? AND processed=true", path)); return p;//from w w w . j a va2s . com }
From source file:pe.gob.mef.gescon.hibernate.impl.UserDaoImpl.java
@Override public Mtuser getMtuserByDNI(String dni) throws Exception { DetachedCriteria criteria = DetachedCriteria.forClass(Mtuser.class); criteria.add(Restrictions.eq("vdni", dni)); return (Mtuser) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria)); }
From source file:pe.gob.mef.gescon.hibernate.impl.CategoriaDaoImpl.java
@Override public Mtcategoria getMtcategoriaById(BigDecimal id) throws Exception { DetachedCriteria criteria = DetachedCriteria.forClass(Mtcategoria.class); criteria.add(Restrictions.eq("ncategoriaid", id)); return (Mtcategoria) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria)); }
From source file:no.dusken.aranea.service.IssueServiceImpl.java
public Issue getCurrentIssue() { Issue i = null;/*from w w w . ja va 2 s . c o m*/ try { List<Issue> list = genericDao.getByNamedQuery("issues_latest", 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:no.dusken.aranea.service.LoginDetailsServiceImpl.java
/** * Locates the user based on the username. In the actual implementation, the search may possibly be case * insensitive, or case insensitive depending on how the implementaion instance is configured. In this case, the * <code>UserDetails</code> object that comes back may have a username that is of a different case than what was * actually requested../* w w w . j av a 2s . co m*/ * * @param username the username presented to the {org.springframework.security.providers.dao.DaoAuthenticationProvider} * @return a fully populated user record (never <code>null</code>) * @throws org.springframework.security.userdetails.UsernameNotFoundException * if the user could not be found or the user has no GrantedAuthority * @throws org.springframework.dao.DataAccessException * if user could not be found for a repository-specific reason */ public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { UserDetails ud = null; try { Map<String, Object> map = new HashMap<String, Object>(); map.put("username", username.toLowerCase()); logger.debug("loading logindetail for username: {}", username); List<LoginDetails> list = genericDao.getByNamedQuery("logindetail_byusername", map); ud = (LoginDetails) DataAccessUtils.uniqueResult(list); } catch (DataAccessException dae) { log.warn("Unable to get UserDetails", dae); } if (ud == null) throw new UsernameNotFoundException("User '" + username + "' not found"); return ud; }
From source file:org.jasig.portlet.blackboardvcportlet.service.impl.LdapUserServiceImpl.java
@Override public BasicUser findUser(String uniqueId) { final AndFilter andFilter = createBaseFilter(); andFilter.and(new EqualsFilter(uniqueIdAttributeName, uniqueId)); final String searchFilter = andFilter.encode(); @SuppressWarnings("unchecked") final List<BasicUser> results = ldapOperations.search("", searchFilter, basicUserAttributeMapper); return DataAccessUtils.uniqueResult(results); }