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

@Override
public String getCodigo(Integer id) {
    Query query = getSession().createQuery("SELECT codigo from Calidad c WHERE c.id = :id");
    query.setParameter("id", id);
    return (String) query.uniqueResult();
}

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

@Override
public Integer getIdPorCodigo(String codigo) {
    Query query = getSession().createQuery("SELECT id from Carga c WHERE c.codigo = :codigo");
    query.setParameter("codigo", codigo);
    return (Integer) query.uniqueResult();
}

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

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

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

@Override
public String getCodigo(Integer id) {
    Query query = getSession().createQuery("SELECT codigo from Carga c WHERE c.id = :id");
    query.setParameter("id", id);
    return (String) query.uniqueResult();
}

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

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

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

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

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

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

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

@Override
public boolean existeFaja(Faja faja) {
    Query query = getSession().createQuery(
            "Select 1 From Faja f Where f.area.id = :idArea AND f.numero = :numero AND f.bloque = :bloque");
    query.setParameter("idArea", faja.getArea().getId());
    query.setParameter("numero", faja.getNumero());
    query.setParameter("bloque", faja.getBloque());
    return (query.uniqueResult() != null);
}

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

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

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

@Override
public Integer getIdPorBloqueYNumero(String bloque, int numero) {
    Query query = getSession()
            .createQuery("Select id From Faja f Where f.numero = :numero AND f.bloque = :bloque");
    query.setParameter("numero", numero);
    query.setParameter("bloque", bloque);
    return (Integer) query.uniqueResult();
}