Example usage for org.hibernate Query setString

List of usage examples for org.hibernate Query setString

Introduction

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

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setString(String name, String val) 

Source Link

Document

Bind a named String-valued parameter.

Usage

From source file:br.com.ln.hibernate.Postgress.java

public static LnPerfil grabPerfilperStDesc(String perStDescricao) {

    Session session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
    Transaction tx = session.beginTransaction();
    LnPerfil lnPerfil = null;/*from w ww  .j  a v a2s. co  m*/

    try {
        Query query = session.getNamedQuery("LnPerfil.findByPerStDescricao");
        query.setString("perStDescricao", perStDescricao);

        List l = query.list();

        if (l != null && !l.isEmpty()) {
            lnPerfil = (LnPerfil) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }
    return lnPerfil;
}

From source file:br.com.ln.hibernate.Postgress.java

public static boolean grabVerificaHistorico(String usuStCodigo) {

    Session session = null;//w  w  w .j  a v a  2s .  c  om
    Transaction tx;
    List<LnHistorico> listHis;
    boolean retorno = false;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnHistorico.findByUsuStCodigo");
        query.setString("usuStCodigo", usuStCodigo);

        listHis = query.list();
        tx.commit();

        System.out.println("lishis : " + listHis.size());

        if (listHis != null) {
            retorno = listHis.size() == 0;
        } else {
            retorno = false;
        }
    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return retorno;
}

From source file:br.com.ln.hibernate.Postgress.java

public static LnCliente grabClienteCpf(String cpf) {

    Session session = null;//from   w  w  w .j av a  2  s  . c  om
    Transaction tx = null;
    LnCliente lnCliente = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnCliente.findByCliStCpf");
        query.setString("cliStCpf", cpf);
        List l = query.list();
        tx.commit();

        if (l != null && !l.isEmpty()) {
            lnCliente = (LnCliente) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return lnCliente;
}

From source file:br.com.ln.hibernate.Postgress.java

public static LnCliente grabClienteCnpj(String cnpj) {

    Session session = null;/*from   ww w .  j a  va 2s . com*/
    Transaction tx = null;
    LnCliente lnCliente = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnCliente.findByCliStCnpj");
        query.setString("cliStCnpj", cnpj);
        List l = query.list();
        tx.commit();
        ;

        if (l != null && !l.isEmpty()) {
            lnCliente = (LnCliente) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return lnCliente;
}

From source file:br.com.ln.hibernate.Postgress.java

public static LnCliente grabClienteNome(String nome) {

    Session session = null;/*from   w  w  w .  j  av a2 s.co m*/
    Transaction tx = null;
    LnCliente lnCliente = null;

    try {
        session = SessionFactoryDbName.getCurrentSessionByName(VarComuns.strDbName);
        tx = session.beginTransaction();

        Query query = session.getNamedQuery("LnCliente.findByCliStNome");
        query.setString("cliStNome", nome);
        List l = query.list();
        tx.commit();
        ;

        if (l != null && !l.isEmpty()) {
            lnCliente = (LnCliente) l.get(0);
        }

    } finally {
        if (session != null && session.isOpen()) {
            session.close();
        }
    }

    return lnCliente;
}

From source file:br.com.muranodesign.dao.impl.ObjetivoDAOImpl.java

License:Creative Commons License

@Override
public float countObjetivosAnoProfessor(int idprofessorFuncionario) {
    Query query = getSession().getNamedQuery("countObjetivosAnoTutoria");
    query.setString("idTutoria", Integer.toString(idprofessorFuncionario));
    return (float) query.list().size();
}

From source file:br.com.muranodesign.dao.impl.ObjetivoDAOImpl.java

License:Creative Commons License

public float countObjetivosAtribuicaoTutoria(int idTutoria) {
    Query query = getSession().getNamedQuery("countObjetivosAtribuicaoTutoria");
    query.setString("idTutoria", Integer.toString(idTutoria));
    return (float) query.list().size();
}

From source file:br.com.muranodesign.dao.impl.PlanejamentoRoteiroDAOImpl.java

License:Creative Commons License

public float countCompletosTutoria(int idTutoria) {
    Query query = getSession().getNamedQuery("countCompletosTutoria");
    query.setString("idTutoria", Integer.toString(idTutoria));
    return (float) query.list().size();
}

From source file:br.com.muranodesign.dao.impl.PlanejamentoRoteiroDAOImpl.java

License:Creative Commons License

public float countCorrigidosTutoria(int idTutoria) {
    Query query = getSession().getNamedQuery("countCorrigidosTutoria");
    query.setString("idTutoria", Integer.toString(idTutoria));
    return (float) query.list().size();
}

From source file:br.com.proj.tasker.dao.impl.UsuarioDAO.java

@Override
public Usuario buscarUsuario(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    String sql = "Select u from Usuario u where email=:email and senha=:pass";
    Query query = session.createQuery(sql);
    query.setString("email", usuario.getEmail());
    query.setString("pass", usuario.getSenha());
    Usuario user = (Usuario) query.uniqueResult();
    session.close();/*from   w  w w.  j  a  v  a2  s .  co  m*/
    return user;
}