Example usage for org.hibernate Query uniqueResult

List of usage examples for org.hibernate Query uniqueResult

Introduction

In this page you can find the example usage for org.hibernate Query uniqueResult.

Prototype

R uniqueResult();

Source Link

Document

Convenience method to return a single instance that matches the query, or null if the query returns no results.

Usage

From source file:bo.com.kibo.dal.impl.UsuarioHibernateDAO.java

@Override
public Integer getIdUsuarioPorEmail(String email) {
    Query query = getSession().createQuery("SELECT id FROM Usuario u WHERE u.email = :email");
    query.setParameter("email", email);
    return (Integer) query.uniqueResult();
}

From source file:bo.com.kibo.dal.impl.UsuarioHibernateDAO.java

@Override
public Usuario logear(String usuario, String pass) {
    Query query = getSession()
            .createQuery("FROM Usuario u WHERE u.nombre = :nombre AND u.contrasena = :contrasena ");
    query.setParameter("nombre", usuario);
    query.setParameter("contrasena", pass);
    return (Usuario) query.uniqueResult();
}

From source file:bo.com.kibo.dal.impl.UsuarioHibernateDAO.java

@Override
public Integer getIdPorNombre(String nombre) {
    Query query = getSession().createQuery("SELECT id from Usuario u WHERE u.nombre = :nombre");
    query.setParameter("nombre", nombre);
    return (Integer) query.uniqueResult();
}

From source file:bo.com.kibo.dal.impl.UsuarioHibernateDAO.java

@Override
public boolean checkId(Integer id) {
    Query query = getSession().createQuery("SELECT 1 from Usuario u WHERE u.id = :id");
    query.setParameter("id", id);
    return (query.uniqueResult() != null);
}

From source file:bo.com.offercruz.dal.base.DAOGenericoHibernate.java

@Override
public T recuperarPorId(ID id) {
    Query query = getSession().createQuery(
            "from " + getPersistentClass().getName() + " c where c.estado > :Estado AND c.id = :Id ");
    query.setParameter("Estado", 0);
    query.setParameter("Id", id);
    return (T) query.uniqueResult();
}

From source file:bo.com.offercruz.dal.base.DAOGenericoHibernate.java

@Override
public boolean checkId(ID id) {
    Query query = getSession()
            .createQuery("SELECT 1 from " + getPersistentClass().getName() + " u WHERE u.id = :Id ");
    query.setParameter("Id", id);
    return (query.uniqueResult() != null);
}

From source file:bo.com.offercruz.dal.impl.CategoriaHibernateDAO.java

@Override
public Integer obtenerIdPorNombre(String nombre) {
    Query query = getSession()
            .createQuery("SELECT id from Categoria c where c.nombre = :Nombre AND c.estado > 0 ");
    query.setParameter("Nombre", nombre);
    return (Integer) query.uniqueResult();
}

From source file:bo.com.offercruz.dal.impl.CategoriaHibernateDAO.java

@Override
public Categoria obtenerPorNombre(String nombre, Integer id) {
    Query query = getSession()
            .createQuery("SELECT 1 from Categoria c where c.nombre = :Nombre AND c.estado > 0 AND c.id != :Id");
    query.setParameter("Nombre", nombre);
    query.setParameter("Id", id);
    return (Categoria) query.uniqueResult();
}

From source file:bo.com.offercruz.dal.impl.CategoriaHibernateDAO.java

@Override
public Categoria obtenerPorNombre(String nombre) {
    Query query = getSession()
            .createQuery("SELECT 1 from Categoria c where c.nombre = :Nombre AND c.estado > 0 ");
    query.setParameter("Nombre", nombre);
    return (Categoria) query.uniqueResult();
}

From source file:bo.com.offercruz.dal.impl.EmpresaHibernateDAO.java

@Override
public Empresa obtenerEmpresa(Integer idUsuario) {
    Query query = getSession().createQuery("Select c from Empresa c join c.usuario u where u.id = :idUsuario ");
    query.setParameter("idUsuario", idUsuario);
    return (Empresa) query.uniqueResult();
}