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.offercruz.dal.impl.EmpresaHibernateDAO.java

@Override
public Integer obtenerIdPorNombre(String nombre) {

    /*Query query = getSession().createQuery("SELECT 1 from " + Categoria.class.getName() + " c where c.nombre = :Nombre AND c.estado > 0 AND c.id != :Id");
     query.setParameter("Nombre", nombre);
     query.setParameter("Id", id);//  ww w.  j av  a2s. co m
     return (Categoria)query.uniqueResult();*/
    Query query = getSession()
            .createQuery("SELECT id from Empresa c where c.razonSocial = :Nombre AND c.estado > 0 ");
    query.setParameter("Nombre", nombre);

    return (Integer) query.uniqueResult();
}

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

@Override
public Empresa obtenerPorNombre(String nombre) {

    /*Query query = getSession().createQuery("SELECT 1 from " + Categoria.class.getName() + " c where c.nombre = :Nombre AND c.estado > 0 AND c.id != :Id");
     query.setParameter("Nombre", nombre);
     query.setParameter("Id", id);/*  w  ww .j av  a 2 s .c  o m*/
     return (Categoria)query.uniqueResult();*/
    Query query = getSession().createQuery(
            "SELECT 1 from " + Empresa.class.getName() + " c where c.razonSocial = :Nombre AND c.estado > 0 ");
    query.setParameter("Nombre", nombre);

    return (Empresa) query.uniqueResult();
}

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

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

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

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

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

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

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

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

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

@Override
public Integer getIdUsuarioPorCorreoElectronico(String email) {
    Query query = getSession().createQuery(
            "SELECT id FROM Usuario u WHERE u.correoElectronico = :CorreoElectronico AND u.estado > 0 ");
    query.setParameter("CorreoElectronico", email);
    return (Integer) query.uniqueResult();
}

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

@Override
public Usuario logear(String usuario, String pass) {
    Query query = getSession()
            .createQuery("FROM Usuario u WHERE u.login = :Login AND u.password = :Password AND u.estado > 0 ");
    query.setParameter("Login", usuario);
    query.setParameter("Password", pass);
    return (Usuario) query.uniqueResult();
}

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

@Override
public Integer getIdPorLogin(String login) {
    Query query = getSession().createQuery("SELECT id from Usuario u WHERE u.login = :Login AND u.estado > 0 ");
    query.setParameter("Login", login);
    return (Integer) query.uniqueResult();
}

From source file:bo.gaceta.rcb.dao.impl.TbInCiiuImpl.java

public String desClase(String idClase) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();/*from  w w  w .  j  a v  a2s.com*/
    session.flush();
    Query query = session.createQuery("SELECT e FROM TbInCiiu e WHERE e.idClase=:_txtBusca")
            .setParameter("_txtBusca", idClase);
    TbInCiiu entities = (TbInCiiu) query.uniqueResult();
    session.getTransaction().commit();
    session.close();
    return entities.getClase();
}