Example usage for org.hibernate Query setParameter

List of usage examples for org.hibernate Query setParameter

Introduction

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

Prototype

@SuppressWarnings("unchecked")
Query<R> setParameter(int position, Object val);

Source Link

Document

Bind a positional query parameter using its inferred Type.

Usage

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();
}

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

@Override
public List<Troza> getTrozasParaTala(Integer idArea) {
    Query query = getSession()
            .createQuery("from Troza t Where t.area.id = :idArea " + "and t.existe = 0 and t.estado = 0");
    query.setParameter("idArea", idArea);
    return query.list();
}

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

@Override
public List<Troza> getTrozasParaExtraccion(Integer idArea) {
    Query query = getSession()
            .createQuery("from Troza t Where t.area.id = :idArea " + "and t.existe = 0 and t.estado = 1");
    query.setParameter("idArea", idArea);
    return query.list();
}

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

@Override
public List<Troza> getTrozasParaMovimiento(Integer idArea) {
    Query query = getSession()
            .createQuery("from Troza t Where t.area.id = :idArea " + "and t.existe = 0 and t.estado = 2");
    query.setParameter("idArea", idArea);
    return query.list();
}

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

@Override
public List<String> getCodigosTrozaParaTala(Integer idArea, String codigoParcial) {
    Query query = getSession().createQuery(
            "Select codigo from Troza t " + "Where t.area.id = :idArea and t.existe = 0 and t.estado = 0"
                    + " and t.codigo LIKE :codigoParcial");
    query.setParameter("idArea", idArea);
    query.setParameter("codigoParcial", codigoParcial + "%");
    return query.list();
}

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

@Override
public List<String> getCodigosTrozaParaExtraccion(Integer idArea, String codigoParcial) {
    Query query = getSession().createQuery(
            "Select codigo from Troza t " + "Where t.area.id = :idArea and t.existe = 0 and t.estado = 1"
                    + " and t.codigo LIKE :codigoParcial");
    query.setParameter("idArea", idArea);
    query.setParameter("codigoParcial", codigoParcial + "%");
    return query.list();
}

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

@Override
public List<String> getCodigosTrozaParaMovimiento(Integer idArea, String codigoParcial) {
    Query query = getSession().createQuery(
            "Select codigo from Troza t " + "Where t.area.id = :idArea and t.existe = 0 and t.estado = 2"
                    + " and t.codigo LIKE :codigoParcial");
    query.setParameter("idArea", idArea);
    query.setParameter("codigoParcial", codigoParcial + "%");
    return query.list();
}

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();
}