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:bbdd.Usuario_RegistradoDAO.java

public static java.util.Iterator iterateUsuario_RegistradoByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From bbdd.Usuario_Registrado as Usuario_Registrado");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//  ww  w  .ja 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:bbdd.Usuario_RegistradoDAO.java

public static java.util.Iterator iterateUsuario_RegistradoByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From bbdd.Usuario_Registrado as Usuario_Registrado");
    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  .c om*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("this", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:br.gov.jfrj.siga.ex.gsa.ExAdaptor.java

License:Open Source License

protected void pushDocIds(DocIdPusher pusher, Date date) throws InterruptedException {
    try {/*from   w w  w. jav  a 2s .  c om*/
        BufferingPusher outstream = new BufferingPusher(pusher);
        ExDao dao = ExDao.getInstance();
        Query q = dao.getSessao().createQuery(getIdsHql());
        q.setDate("dt", date);
        @SuppressWarnings("rawtypes")
        Iterator i = q.iterate();
        while (i.hasNext()) {
            DocId id = new DocId("" + i.next());
            outstream.add(id);
        }
        outstream.forcePush();
    } finally {
        ExDao.freeInstance();
    }
}

From source file:br.gov.jfrj.siga.hibernate.ExDao.java

License:Open Source License

@SuppressWarnings("unchecked")
public Iterator<ExMobil> consultarParaTransferirEmLote(DpLotacao lot) {
    final Query query = getSessao().getNamedQuery("consultarParaTransferirEmLote");
    query.setLong("lotaIni", lot.getIdLotacaoIni());
    //return query;
    return query.iterate();
}

From source file:businesslogic.accounting.job.JobDAO.java

public static java.util.Iterator iterateJobByQuery(PersistentSession session, String condition, String orderBy)
        throws PersistentException {
    StringBuffer sb = new StringBuffer("From businesslogic.accounting.job.Job as Job");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//  w  w w.  j  a v 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:businesslogic.accounting.job.JobDAO.java

public static java.util.Iterator iterateJobByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From businesslogic.accounting.job.Job as Job");
    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());
        query.setLockMode("Job", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:businesslogic.accounting.job.ProgrammingDAO.java

public static java.util.Iterator iterateProgrammingByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer("From businesslogic.accounting.job.Programming as Programming");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {// w  w w .ja va  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:businesslogic.accounting.job.ProgrammingDAO.java

public static java.util.Iterator iterateProgrammingByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From businesslogic.accounting.job.Programming as Programming");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/* ww  w  .j  av  a2s.c o m*/
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Programming", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:businesslogic.accounting.job.ProjectManagementDAO.java

public static java.util.Iterator iterateProjectManagementByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From businesslogic.accounting.job.ProjectManagement as ProjectManagement");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/* www  . j  a  v  a2  s .  c om*/
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:businesslogic.accounting.job.ProjectManagementDAO.java

public static java.util.Iterator iterateProjectManagementByQuery(PersistentSession session, String condition,
        String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From businesslogic.accounting.job.ProjectManagement as ProjectManagement");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {// ww  w.  ja v a 2 s . com
        Query query = session.createQuery(sb.toString());
        query.setLockMode("ProjectManagement", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}