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.proj.tasker.dao.impl.TarefaDAO.java

@Override
public List<Tarefa> buscaTarProjCargo(Integer id, Integer id2) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Query query = session.createQuery(
            "Select tar from Tarefa as tar JOIN tar.projeto as pro WHERE pro.idProj = :id AND tar.status<>'Desativada' AND tar.status<>'Finalizada' AND tar.cargo.idCargo = :id2");
    query.setParameter("id", id);
    query.setParameter("id2", id2);
    List<Tarefa> tars = query.list();
    session.close();//from  w w  w  . ja  v  a  2 s . c o m
    return tars;
}

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

@Override
public List<Telefone> listarTodos() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    List<Telefone> tels = session.createQuery("from Telefone").list();
    session.close();//from   ww w . ja v  a 2s .c o  m
    return tels;
}

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

@Override
public Telefone listarPorUser(Integer id) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Telefone tel = (Telefone) session.createQuery("from Telefone where id_pes = :id").setParameter("id", id)
            .uniqueResult();//from   ww w  .  j  ava 2 s  .c o m
    session.close();
    return tel;
}

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();/*  w  w  w .ja v  a2s  .c  o m*/
    return user;
}

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

@Override
public List<Usuario> buscarTodos(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    List<Usuario> users = session.createQuery("from Usuario").list();
    session.close();//  ww  w .j av  a2  s .  c  o m
    return users;
}

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

@Override
public Usuario buscarPorMail(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Usuario user = (Usuario) session.createQuery("from Usuario where email = :mail")
            .setParameter("mail", usuario.getEmail()).uniqueResult();
    session.close();//from  ww  w .  j a  va 2s  .  c  om
    return user;
}

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

@Override
public Usuario buscarPorId(Usuario usuario) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Usuario user = (Usuario) session.createQuery("from Usuario where id_user = :id")
            .setParameter("id", usuario.getIdUser()).uniqueResult();
    session.close();/*from  w ww .ja v a 2 s  .c o  m*/
    return user;
}

From source file:br.com.projetoweb.model.dao.LivroDAOImp.java

/**
 *
 * @return//from  w ww  .  j  a va  2s  .co  m
 */
@SuppressWarnings("override")
public List<Livro> list() {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction t = session.beginTransaction();
    List lista = session.createQuery("from Livro").list();
    t.commit();
    return lista;
}