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:abd.p1.bd.UsuarioDAO.java

public ArrayList obtenerUsuarios() {
    String sql = "SELECT nombre, fecha_nac, foto FROM usuarios";
    Session sesion = sf.openSession();//from  w w  w .j a v a 2 s.  c om
    Query consulta = sesion.createQuery(sql);
    ArrayList<Usuario> usuarios = (ArrayList<Usuario>) consulta.list();
    return usuarios;
}

From source file:abstractDao.AbstractDao.java

protected List<T> findAll(Class clazz) {
    List<T> objects = null;
    try {//from  w  w  w .j a va 2s  .c  o m
        startOperation();
        Query query = session.createQuery("from " + clazz.getName());
        objects = query.list();
        tx.commit();
    } catch (HibernateException e) {
        handleException(e);
    } finally {
        HibernateFactory.close(session);
    }
    return objects;
}

From source file:ac.cr.una.backend.dao.AuthorDaoImpl.java

@Override
public Author findByName(String name) {
    Author autor = null;/* ww  w .  ja  va 2  s .  co  m*/
    Query query = session.createQuery("from Author where nombre = :nombre ");//name
    query.setParameter("nombre", name);

    if (query.list().size() > 0) {
        autor = (Author) query.list().get(0);
    }

    return autor;
}

From source file:ac.cr.una.backend.dao.AuthorDAOImple.java

@Override
public Author findByName(String name) {
    Author author = null;/* w w w .  j ava  2s .  co m*/
    Query query = session.createQuery("from Author where name = :name ");
    query.setParameter("name", name);

    if (query.list().size() > 0) {
        author = (Author) query.list().get(0);
    }

    return author;
}

From source file:ac.cr.una.backend.dao.BookTypeDAOImple.java

@Override
public BookType findByName(String name) {
    BookType bookType = null;//from  www  . j a v a 2 s  .  c om
    Query query = session.createQuery("from Author where name = :name ");
    query.setParameter("name", name);

    if (query.list().size() > 0) {
        bookType = (BookType) query.list().get(0);
    }

    return bookType;
}

From source file:ac.cr.una.backend.dao.StudentDAOHibernateImpl.java

License:Open Source License

@Override
public Student findById(int id) {
    Student student = null;/* w  w w .  j  a  v  a 2s.co  m*/
    Query query = session.createQuery("from Student where id = :id ");
    query.setParameter("id", id);

    if (query.list().size() > 0) {
        student = (Student) query.list().get(0);
    }

    return student;
}

From source file:ac.cr.una.lab.dao.UniversidadDAOHibernateImpl.java

/**
 *
 * @param id/* w  w  w  .  j a  v  a  2  s . com*/
 * @return
 */
@Override
public Universidad findById(int id) {
    Universidad universidad = null;
    Query query = session.createQuery("from university where id = :id ");
    query.setParameter("id", id);

    if (query.list().size() > 0) {
        universidad = (Universidad) query.list().get(0);
    }

    return universidad;
}

From source file:AccesoDatos.AdministradorDAO.java

@Override
public List<Administrador> findAllByOther(String o, String p) {
    List<Administrador> lista = null;
    try {//ww  w.j a  v a  2 s .co  m
        iniciaOperacion();
        Query query = getSesion().createQuery("from Administrador where c_categoria = '" + o + "'");//Esto esta por verse
        lista = query.list();
    } finally {
        getSesion().close();
    }

    return lista;
}

From source file:AccesoDatos.AlumnoDAO.java

@Override
public List<Alumno> findAllByOther(String o, String p) {
    List<Alumno> lista = null;
    try {//from   w  w w.ja  v  a  2 s.  c  om
        iniciaOperacion();
        Query query = getSesion().createQuery("from Alumno where nombre = '" + o + "'");//Esto esta por verse
        lista = query.list();
    } finally {
        getSesion().close();
    }

    return lista;
}

From source file:AccesoDatos.CarreraDAO.java

@Override
public List<Carrera> findAllByOther(String o, String p) {
    List<Carrera> lista = null;
    try {/*from www. j  a v a2 s  .c o  m*/
        iniciaOperacion();
        Query query = getSesion().createQuery("from Carrera where c_categoria = '" + o + "'");//Esto esta por verse
        lista = query.list();
    } finally {
        getSesion().close();
    }

    return lista;
}