List of usage examples for org.hibernate Query iterate
Iterator<R> iterate();
From source file:CRUD.Relatorios.Geral.GeralController.java
public void GerarRelatorioGeral(String dateinicial, String datefinal) throws ParseException { DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd"); Date startDate = (Date) formatter.parse(dateinicial); Date endDate = (Date) formatter.parse(datefinal); // Assign values to startDate and endDate String hqlQuery = "FROM exames WHERE data BETWEEN :startDate AND :endDate"; String hqlQuery2 = "FROM resultados WHERE data BETWEEN :startDate AND :endDate"; String hqlQuery3 = "FROM pagamentos WHERE data BETWEEN :startDate AND :endDate"; Session sessao = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = sessao.beginTransaction(); Query query = sessao.createQuery(hqlQuery); Iterator iterador = query.iterate(); while (iterador.hasNext()) { Exame exam = (Exame) iterador.next(); System.out.println(exam.getNome()); }/*ww w . j a v a 2 s. com*/ }
From source file:dados.hibernate.DAO.AlbumPDAO.java
public static java.util.Iterator iterateAlbumPByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From AlbumP as AlbumP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {//from w ww .j a v a 2 s. c o m Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:dados.hibernate.DAO.AlbumPDAO.java
public static java.util.Iterator iterateAlbumPByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From AlbumP as AlbumP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {//from w w w . j a va 2 s .c o m Query query = session.createQuery(sb.toString()); query.setLockMode("AlbumP", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:dados.hibernate.DAO.ArtistaPDAO.java
public static java.util.Iterator iterateArtistaPByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From ArtistaP as ArtistaP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w ww. j av a 2 s .c om*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:dados.hibernate.DAO.ArtistaPDAO.java
public static java.util.Iterator iterateArtistaPByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From ArtistaP as ArtistaP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {//from w ww .j a v a 2 s. co m Query query = session.createQuery(sb.toString()); query.setLockMode("ArtistaP", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:dados.hibernate.DAO.MusicaPDAO.java
public static java.util.Iterator iterateMusicaPByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From MusicaP as MusicaP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w ww. j av a 2 s . c o m*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:dados.hibernate.DAO.MusicaPDAO.java
public static java.util.Iterator iterateMusicaPByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From MusicaP as MusicaP"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w w w .jav a2 s . c om*/ Query query = session.createQuery(sb.toString()); query.setLockMode("MusicaP", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:DAO.conexionHibernate.java
/** * devuelve una list de Clientes./*from ww w.java 2s. c om*/ * * @return */ public List mostrarCliente() { ss.close(); ss = NewHibernateUtil.getSessionFactory().openSession(); //creamos la clase Clientes cliente; //creamos donde se almacenar List<Clientes> listaClientes = new ArrayList(); //muestra todos los clientes Query q = ss.createQuery("from Clientes"); Iterator<Clientes> it = q.iterate(); while (it.hasNext()) { cliente = (Clientes) it.next(); listaClientes.add(cliente); } return listaClientes; }
From source file:DAO.conexionHibernate.java
/** * devuelve una list de Clientes.//w w w. j a v a 2s. com * * @return */ public List mostrarTrabajador() { ss.close(); ss = NewHibernateUtil.getSessionFactory().openSession(); //creamos la clase Trabajador trabajador; //creamos donde se almacenar List<Trabajador> listaClientes = new ArrayList(); //muestra todos los clientes Query q = ss.createQuery("from Trabajador"); Iterator<Trabajador> it = q.iterate(); while (it.hasNext()) { trabajador = (Trabajador) it.next(); listaClientes.add(trabajador); } return listaClientes; }
From source file:de.elatexam.editor.pages.subtaskdefs.PrivateSubtasksDataProvider.java
License:Open Source License
@Override public Iterator<SubTaskDef> iterator(final int first, final int count) { final Session sess = Databinder.getHibernateSession(getFactoryKey()); final Query q = sess.createQuery(createQueryString()); q.setFirstResult(first);/*from w ww . j a va 2 s .c o m*/ q.setMaxResults(count); // q.setResultTransformer(RemoveNullResultTransformer.INSTANCE); return q.iterate(); }