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.PatioHibernateDAO.java

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

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

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

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

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

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

@Override
public Integer getIdPatioPorNombre(String nombre, Integer idArea) {
    Query query = getSession()
            .createQuery("SELECT id from Patio p " + "WHERE p.nombre = :nombre AND p.area.id = :idArea");
    query.setParameter("nombre", nombre);
    query.setParameter("idArea", idArea);
    return (Integer) query.uniqueResult();
}

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

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

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

@Override
public Integer getIdPorDescripcion(String descripcion) {
    Query query = getSession().createQuery("SELECT id from Rol r WHERE r.descripcion = :descripcion");
    query.setParameter("descripcion", descripcion);
    return (Integer) query.uniqueResult();
}

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

@Override
public String getDescripcion(Integer id) {
    Query query = getSession().createQuery("SELECT descripcion from Rol r WHERE r.id = :id");
    query.setParameter("id", id);
    return (String) query.uniqueResult();
}

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

@Override
public Integer getIdPorCodigoArea(String codigo, Integer idArea) {
    Query query = getSession()
            .createQuery("Select id From Troza t Where t.codigo = :codigo AND t.area.id = :idArea");
    query.setParameter("idArea", idArea);
    query.setParameter("codigo", codigo);
    return (Integer) query.uniqueResult();
}

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

@Override
public boolean checkNumero(Integer numero) {
    Query query = getSession().createQuery("Select 1  From Troza t Where t.numero = :numero");
    query.setParameter("numero", numero);
    return (query.uniqueResult() != null);
}

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

@Override
public String getCodigo(Integer numero) {
    Query query = getSession().createQuery("Select codigo From Troza t Where t.numero = :numero");
    query.setParameter("numero", numero);
    return (String) query.uniqueResult();
}