Example usage for org.hibernate Query iterate

List of usage examples for org.hibernate Query iterate

Introduction

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

Prototype

Iterator<R> iterate();

Source Link

Document

Return the query results as an Iterator.

Usage

From source file:edu.mgupi.pass.db.sensors.SensorTypesFactory.java

public static java.util.Iterator iterateSensorTypesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.sensors.SensorTypes as SensorTypes");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*from   ww w.j a  v a2s  . co  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSensorTypesByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.MaterialsFactory.java

public static java.util.Iterator iterateMaterialsByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.Materials as Materials");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   w  w  w  .j  av  a  2  s .co m
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateMaterialsByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.MaterialsFactory.java

public static java.util.Iterator iterateMaterialsByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.Materials as Materials");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from w  ww . ja va 2 s  .  c  o m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateMaterialsByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfaceClassesFactory.java

public static java.util.Iterator iterateSurfaceClassesByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.SurfaceClasses as SurfaceClasses");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from ww  w .jav a  2s  .  c  o m
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateSurfaceClassesByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfaceClassesFactory.java

public static java.util.Iterator iterateSurfaceClassesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.SurfaceClasses as SurfaceClasses");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/* ww w . j  a  v  a2 s  .  c  o  m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error(
                "iterateSurfaceClassesByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfacesFactory.java

public static java.util.Iterator iterateSurfacesByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.Surfaces as Surfaces");
    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.c  om*/
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSurfacesByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfacesFactory.java

public static java.util.Iterator iterateSurfacesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.Surfaces as Surfaces");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  w  ww .  j a  va2s  .  c o  m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSurfacesByQuery(PersistentSession session, String condition, String orderBy)", e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfaceTypesFactory.java

public static java.util.Iterator iterateSurfaceTypesByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.SurfaceTypes as SurfaceTypes");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  w w  w.j a  v  a  2 s  . c  o  m
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSurfaceTypesByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.mgupi.pass.db.surfaces.SurfaceTypesFactory.java

public static java.util.Iterator iterateSurfaceTypesByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From edu.mgupi.pass.db.surfaces.SurfaceTypes as SurfaceTypes");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*w  w  w.j  av  a  2  s  . co m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        _logger.error("iterateSurfaceTypesByQuery(PersistentSession session, String condition, String orderBy)",
                e);
        throw new PersistentException(e);
    }
}

From source file:edu.scripps.fl.pubchem.app.curves.AIDStage.java

License:Apache License

@Override
public void process(Object obj) throws StageException {
    try {//w  w  w .  j  a va  2  s.  c  o m
        Integer aid = (Integer) obj;
        List<Double> concentrations = getConcentrations(aid);

        Query query2 = getSession().createQuery("from PCAssayResult where assay.AID = ? and SID = ?");
        // get top 10000 results from reference aid
        int counter = 0;
        Query query = getSession().createQuery(
                "from PCAssayResult where assay.AID = ? AND ( outcome = 'Active' OR outcome = 'Probe' ) ORDER BY rankScore desc");
        query.setInteger(0, getReferenceAID());
        Iterator<PCAssayResult> iter = query.iterate();
        while (iter.hasNext() && counter++ < getTopX()) {
            PCAssayResult referenceResult = iter.next();
            referenceResult.getTestedValues();
            emit(new Object[] { referenceConcentrations, referenceResult });

            query2.setInteger(0, aid);
            query2.setLong(1, referenceResult.getSID());
            Iterator<PCAssayResult> iter2 = query2.iterate();
            while (iter2.hasNext()) {
                PCAssayResult result = iter2.next();
                result.getTestedValues();
                emit(new Object[] { concentrations, result });
            }
        }
    } catch (Exception ex) {
        throw new StageException(this, ex);
    }
}