List of usage examples for org.hibernate Query iterate
Iterator<R> iterate();
From source file:edu.scripps.fl.pubchem.app.curves.AssayStage.java
License:Apache License
@Override public void process(Object obj) throws StageException { try {//w w w . jav a2s .c o m Integer aid = (Integer) obj; PCAssay assay = (PCAssay) getSession().load(PCAssay.class, aid); List<Double> concentrations = new ArrayList(); for (PCAssayColumn column : assay.getColumns()) { Double conc = column.getTestedConcentration(); if (conc != null) { conc = conc * 1E-6; // conc. always in uM concentrations.add(conc); } } Query query = getSession().createQuery( "from PCAssayResult where assay.AID = ? AND ( outcome = 'Active' OR outcome = 'Probe' ) ORDER BY rankScore desc"); query.setInteger(0, assay.getAID()); int counter = 0; Iterator<PCAssayResult> iter = query.iterate(); while (iter.hasNext() && counter++ < 10000) { PCAssayResult result = iter.next(); result.getTestedValues(); emit(new Object[] { concentrations, result }); } } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:entities.Candidate.java
public static java.util.Iterator iterateCandidateByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.Candidate as Candidate"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w ww. j a va 2 s . co m*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.Candidate.java
public static java.util.Iterator iterateCandidateByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.Candidate as Candidate"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w w w. ja va 2 s. co m*/ Query query = session.createQuery(sb.toString()); query.setLockMode("Candidate", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.County.java
public static java.util.Iterator iterateCountyByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.County as County"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w w w . ja v a 2s .com*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.County.java
public static java.util.Iterator iterateCountyByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.County as County"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from ww w. ja v a2 s .c om*/ Query query = session.createQuery(sb.toString()); query.setLockMode("County", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.District.java
public static java.util.Iterator iterateDistrictByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.District as District"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w w w. j a va2 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:entities.District.java
public static java.util.Iterator iterateDistrictByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.District as District"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from www . j a v a2 s .c o m*/ Query query = session.createQuery(sb.toString()); query.setLockMode("District", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.Division.java
public static java.util.Iterator iterateDivisionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.Division as Division"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from www. j a v a 2 s . com*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.Division.java
public static java.util.Iterator iterateDivisionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.Division as Division"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from ww w.ja v a 2s. c o m*/ Query query = session.createQuery(sb.toString()); query.setLockMode("Division", lockMode); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }
From source file:entities.Group_detail.java
public static java.util.Iterator iterateGroup_detailByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException { StringBuffer sb = new StringBuffer("From entities.Group_detail as Group_detail"); if (condition != null) sb.append(" Where ").append(condition); if (orderBy != null) sb.append(" Order By ").append(orderBy); try {/*from w ww.j ava 2 s . com*/ Query query = session.createQuery(sb.toString()); return query.iterate(); } catch (Exception e) { e.printStackTrace(); throw new PersistentException(e); } }