Example usage for org.hibernate Session createQuery

List of usage examples for org.hibernate Session createQuery

Introduction

In this page you can find the example usage for org.hibernate Session createQuery.

Prototype

@Override
    org.hibernate.query.Query createQuery(CriteriaDelete deleteQuery);

Source Link

Usage

From source file:br.com.moises.suport.EmbarqueSuport.java

public List<Embarque> getEmbarquesAbertoByQuery() {
    Session s = Dao().getSession();
    Dao().begin(s);/*  ww  w.j a v a 2s  .  c om*/
    try {
        Query query = s.createQuery("SELECT E FROM Embarque E WHERE E.status =:STATUS");
        query.setParameter("status", StatusEmbarque.VAZIO);
        query.setParameter("status", StatusEmbarque.CARREGANDO);
        List<Embarque> embarques = query.list();
        embarques.size();
        return embarques;
    } catch (Exception e) {
        return null;
    } finally {
        Dao().commit(s);

    }

}

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

@Override
public List<Cargo> getCargoUser(Integer id, Integer id2) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Query query = session.createQuery("from Cargo where id_admin = :id AND id_grupo = :id2");
    query.setParameter("id", id);
    query.setParameter("id2", id2);
    List<Cargo> cargos = query.list();
    return cargos;
}

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

@Override
public List<Cargo> buscaCargosGru(Integer id) {
    Session session = HibernateUtil.createSessionFactory().openSession();
    Query query = session.createQuery("from Cargo where id_grupo = :id");
    query.setParameter("id", id);
    List<Cargo> cargos = query.list();
    return cargos;
}

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

@Override
public List<Cartaocred> listarTodos() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    List<Cartaocred> cards = session.createQuery("from Cartaocred").list();
    session.close();/*  ww  w.  j av  a  2 s .c om*/
    return cards;
}

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

@Override
public Cartaocred listarPorUser(Integer id) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Cartaocred card = (Cartaocred) session.createQuery("from Cartaocred where id_pes = :id")
            .setParameter("id", id).uniqueResult();
    session.close();/*from ww w.j  a  v a2  s.  c  o m*/
    return card;
}

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

@Override
public List<Endereco> listarTodos() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    List<Endereco> ends = session.createQuery("from Endereco").list();
    session.close();/*from  w  ww. j av a  2s  .c  o  m*/
    return ends;
}

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

@Override
public Endereco listarPorUser(Integer id) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Endereco end = (Endereco) session.createQuery("from Endereco where id_pes = :id").setParameter("id", id)
            .uniqueResult();//from www  . j  av  a 2  s  .c o m
    session.close();
    return end;
}

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

@Override
public List<Grupo> buscaGrupoAtivo(Integer id) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    List<Grupo> grupos = session.createQuery(
            "Select gru from Grupo as gru JOIN gru.ativmembroses as ativ WHERE ativ.pessoa.idPes = :id AND gru.ativo = 't'")
            .setParameter("id", id).list();
    session.close();/*w w w. j a v a2 s.  c om*/
    return grupos;
}

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

@Override
public Perfil buscaAdmin() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Perfil perfil = (Perfil) session.createQuery("from Perfil where id_perf = 1").uniqueResult();
    session.close();//  w w  w.  j  a  va 2s .  com
    return perfil;
}

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

@Override
public Perfil buscaGerente() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Perfil perfil = (Perfil) session.createQuery("from Perfil where id_perf = 2").uniqueResult();
    session.close();//from  ww w.j a  va  2 s  . c o  m
    return perfil;
}