Example usage for org.hibernate Query list

List of usage examples for org.hibernate Query list

Introduction

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

Prototype

List<R> list();

Source Link

Document

Return the query results as a List.

Usage

From source file:app.SpHelper.java

@SuppressWarnings("unchecked")
public List<Sanpham> getSPList() {
    spList = new ArrayList<Sanpham>();
    try {/*from www  . j  a v a2 s. c  o m*/
        org.hibernate.Transaction tx = session.beginTransaction();
        Query q = session.createQuery("from Sanpham as sanpham");
        spList = (List<Sanpham>) q.list();
    } catch (Exception e) {
        spList = null;
        e.printStackTrace();
    }
    return spList;
}

From source file:appcostal.model.DAO.java

public List<Hermano> hermanosDisponibles() {
    List<Hermano> hermanos;
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;//from  w ww . jav  a2s. c o m
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Hermano");
    hermanos = (List<Hermano>) q.list();
    tx.commit();
    se.close();
    return hermanos;
}

From source file:appcostal.model.DAO.java

public Hermano buscaHermano(String email, String clave) {
    Hermano hermano = null;/*w  ww.  j a  v  a2s. c o  m*/
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Hermano where email='" + email + "' and clave='" + clave + "'");
    List<Hermano> lista = (List<Hermano>) q.list();
    if (!lista.isEmpty()) {
        hermano = lista.get(0);
    }
    tx.commit();
    se.close();
    return hermano;
}

From source file:appcostal.model.DAO.java

public Hermano obtenerHermano(String dni) {
    Hermano hermano = null;/*  www. j  ava 2s .  c  o m*/
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Hermano where dni='" + dni + "'");
    List<Hermano> lista = (List<Hermano>) q.list();
    if (!lista.isEmpty()) {
        hermano = lista.get(0);
    }
    tx.commit();
    se.close();
    return hermano;
}

From source file:appcostal.model.DAO.java

public List<Paso> pasosDisponibles() {
    List<Paso> pasos;//w  w w .j  a  va2 s.  co  m
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Paso");
    pasos = (List<Paso>) q.list();
    tx.commit();
    se.close();
    return pasos;
}

From source file:appcostal.model.DAO.java

public List<Iguala> igualasDisponibles() {
    List<Iguala> igualas;/*from  w  ww.j a va2 s .  co m*/
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Iguala");
    igualas = (List<Iguala>) q.list();
    tx.commit();
    se.close();
    return igualas;
}

From source file:appcostal.model.DAO.java

public Iguala obtenerIguala(String idiguala) {
    Iguala iguala = null;// w w w .jav  a2s .  c  om
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Iguala where idiguala='" + idiguala + "'");
    List<Iguala> lista = (List<Iguala>) q.list();
    if (!lista.isEmpty()) {
        iguala = lista.get(0);
    }
    tx.commit();
    se.close();
    return iguala;
}

From source file:appcostal.model.DAO.java

public List<Recorrido> recorridosDisponibles() {
    List<Recorrido> recorridos;
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;/*from w w  w  . j a va  2s  .c  o m*/
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Recorrido");
    recorridos = (List<Recorrido>) q.list();
    tx.commit();
    se.close();
    return recorridos;
}

From source file:appcostal.model.DAO.java

public Recorrido obtenerRecorrido(String idrecorrido) {
    Recorrido recorrido = null;//from   ww w  .j  a  va  2 s  .co m
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Recorrido where idrecorrido='" + idrecorrido + "'");
    List<Recorrido> lista = (List<Recorrido>) q.list();
    if (!lista.isEmpty()) {
        recorrido = lista.get(0);
    }
    tx.commit();
    se.close();
    return recorrido;
}

From source file:appcostal.model.DAO.java

public Hermandad obtenerHermandad(String idhermandad) {
    Hermandad hermandad = null;/*www.ja v  a2  s  .c  o  m*/
    SessionFactory s = HibernateUtil.getSessionFactory();
    Session se;
    se = s.openSession();
    Transaction tx = se.beginTransaction();
    Query q = se.createQuery("From Hermandad where idhermandad='" + idhermandad + "'");
    List<Hermandad> lista = (List<Hermandad>) q.list();
    if (!lista.isEmpty()) {
        hermandad = lista.get(0);
    }
    tx.commit();
    se.close();
    return hermandad;
}