List of usage examples for org.hibernate Query uniqueResult
R uniqueResult();
From source file:bookstore.dao.generic.GenericDAOImpl.java
public T findOne(Query query) { T t; t = (T) query.uniqueResult(); return t; }
From source file:br.cafw.si2at.dao.LoginDAO.java
public Usuarios login(String nome, String senha) { String hql = "from Usuarios u where u.login = :login and u.senha = md5(:senha)"; Query q = HibernateUtil.getSession().createQuery(hql); q.setString("login", nome); q.setString("senha", senha); return (Usuarios) q.uniqueResult(); }
From source file:br.com.arsmachina.authentication.dao.hibernate.UserDAOImpl.java
License:Apache License
/** * Finds the user with a given login and password. The login search is case-insensitive. * /*from w w w . j a v a 2 s . c o m*/ * @see br.com.arsmachina.authentication.dao.UserDAO#findByLoginAndPassword(java.lang.String, * java.lang.String) */ public User findByLoginAndPassword(String login, String password) { Session session = getSession(); Query query = session .createQuery("from User where lowercase(login) = :login and " + "password = :password"); query.setParameter("login", login.toLowerCase()); query.setParameter("password", passwordEncrypter.encrypt(password)); return (User) query.uniqueResult(); }
From source file:br.com.arsmachina.authentication.dao.hibernate.UserDAOImpl.java
License:Apache License
/** * Finds an user by its login. The search is case-insensitive. * // ww w .j a va 2 s .c om * @see br.com.arsmachina.authentication.dao.UserDAO#findByLogin(java.lang.String) */ public User findByLogin(String login) { Session session = getSession(); Query query = session.createQuery("from User where lower(login) = :login"); query.setParameter("login", login.toLowerCase()); return (User) query.uniqueResult(); }
From source file:br.com.arsmachina.authentication.dao.hibernate.UserDAOImpl.java
License:Apache License
public boolean hasUserWithLogin(String login) { Query query = getSession().createQuery("select count (distinct u) from User u where lower(login) = :login"); query.setParameter("login", login.toLowerCase()); Long result = (Long) query.uniqueResult(); return result > 0; }
From source file:br.com.barterserver.dao.UserDAO.java
public User getUserByCredentials(String email, String password) { Query q = session.createQuery("from User u where u.email = :email and u.password = :password "); q.setParameter("email", email); q.setParameter("password", password); return (User) q.uniqueResult(); }
From source file:br.com.barterserver.dao.UserDAO.java
public User getUserByEmail(String email) { Query q = session.createQuery("from User where u.email = :email"); q.setParameter("email", email); return (User) q.uniqueResult(); }
From source file:br.com.bibliotecasj.DAO.FrequenciaDAO.java
@Override public Frequencia buscar(String cpf) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Frequencia fre = null;//from w ww . j a va2 s . c o m try { Query consulta = sessao.getNamedQuery("frequencia.BuscarCpf"); consulta.setString("cpf", cpf); fre = (Frequencia) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return fre; }
From source file:br.com.bibliotecasj.DAO.LoginDAO.java
@Override public Login buscar(String login) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Login log = null;/* w ww. j a va 2s . c o m*/ try { Query consulta = sessao.getNamedQuery("Login.Buscarlog"); consulta.setString("login", login); log = (Login) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return log; }
From source file:br.com.bibliotecasj.DAO.UsuarioDAO.java
@Override public Usuario buscar(String cpf) { Session sessao = HibernateUtil.getSessionFactory().openSession(); Usuario usu = null;//w w w .ja v a 2 s . c o m try { Query consulta = sessao.getNamedQuery("Usuario.BuscarCpf"); consulta.setString("cpf", cpf); usu = (Usuario) consulta.uniqueResult(); } catch (RuntimeException ex) { throw ex; } finally { sessao.close(); } return usu; }