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:com.Accenture.Servlet.Viewlearner.java

/**
 * Handles the HTTP <code>GET</code> method.
 *
 * @param request servlet request/*w  w w . j  av a  2s  .co  m*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    Session session;
    try (PrintWriter out = response.getWriter()) {
        /* TODO output your page here. You may use following sample code. */
        out.println("<!DOCTYPE html>");
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet Viewlearner</title>");
        out.println("</head>");
        out.println("<body>");
        SessionFactory sessionfactory = new org.hibernate.cfg.Configuration().configure().buildSessionFactory();
        session = sessionfactory.openSession();
        session.beginTransaction();
        String hgl = "from learnerspojo learner";
        org.hibernate.Query query = session.createQuery(hgl);
        //query.setParameter(hgl, out);
        System.out.println("Reading values");
        for (Iterator it = query.iterate(); it.hasNext();) {
            learnerspojo model = (learnerspojo) it.next();

            out.println("Reading the location table");
            out.println("<h2>" + model.getLID() + "</h2>");
            out.println("<h2>" + model.getLName() + "</h2>");
            out.println("<h2>" + model.getLSurname() + "</h2>");
            out.println("</br>");
        }
        session.getTransaction().commit();
        System.out.println("Done!");
        out.println("<h1>Servlet Viewlearner at " + request.getContextPath() + "</h1>");
        out.println("</body>");
        out.println("</html>");
    }
}

From source file:com.anite.zebra.hivemind.om.state.ZebraProcessInstance.java

License:Apache License

/**
 * @param results/*from  w  w w  .  ja v a 2s.  c  o m*/
 * @param q
 * @throws HibernateException
 */
@Transient
private void recursivelyQueryChildProcesses(List<ZebraProcessInstance> results, Query q)
        throws HibernateException {
    // Recursive Process children
    Stack<ZebraProcessInstance> checkList = new Stack<ZebraProcessInstance>();
    checkList.push(this);
    while (!checkList.isEmpty()) {
        ZebraProcessInstance processInstance = checkList.pop();
        q.setLong("guid", processInstance.getProcessInstanceId().longValue());
        for (Iterator it = q.iterate(); it.hasNext();) {
            ZebraProcessInstance childProcess = (ZebraProcessInstance) it.next();
            results.add(childProcess);
            checkList.push(childProcess);
        }
    }
}

From source file:com.boaglio.jroadmap.model.dao.HibernateRoadmapDAO.java

License:Open Source License

public List findAllByTask() {
    Query query = session.createQuery(COMMON_SQL + " order by p.task.name");
    List roadmap = new ArrayList();
    for (Iterator it = query.iterate(); it.hasNext();) {
        Plan p = (Plan) it.next();/*from   ww  w . java2 s  .  co m*/
        roadmap.add(p);
    }
    return roadmap;
}

From source file:com.boaglio.jroadmap.model.dao.HibernateRoadmapDAO.java

License:Open Source License

public List findAllByPriority() {
    Query query = session.createQuery(COMMON_SQL + " order by p.priority");
    List roadmap = new ArrayList();
    for (Iterator it = query.iterate(); it.hasNext();) {
        Plan p = (Plan) it.next();/*w  w w . j  a  v  a2 s. co  m*/
        roadmap.add(p);
    }
    return roadmap;
}

From source file:com.boaglio.jroadmap.model.dao.HibernateRoadmapDAO.java

License:Open Source License

public List findAllByStatus() {
    Query query = session.createQuery(COMMON_SQL + " order by p.status");
    List roadmap = new ArrayList();
    for (Iterator it = query.iterate(); it.hasNext();) {
        PlanVO p = (PlanVO) it.next();/*from   w  ww  .  j av a2 s .c o m*/
        roadmap.add(p);
    }
    return roadmap;
}

From source file:com.boaglio.jroadmap.model.dao.HibernateRoadmapDAO.java

License:Open Source License

public List findAllByResponsible() {
    Query query = session.createQuery(COMMON_SQL + " order by p.responsible.name");
    List roadmap = new ArrayList();
    for (Iterator it = query.iterate(); it.hasNext();) {
        PlanVO p = (PlanVO) it.next();/*from w  w w  .jav  a2s.  co m*/
        roadmap.add(p);
    }
    return roadmap;
}

From source file:com.boaglio.jroadmap.model.dao.HibernateRoadmapDAO.java

License:Open Source License

public List findAllByReleaseDate() {
    Query query = session.createQuery(COMMON_SQL + " order by p.releaseDate");
    List roadmap = new ArrayList();
    for (Iterator it = query.iterate(); it.hasNext();) {
        Plan p = (Plan) it.next();//from   w  w  w. ja v a 2 s  .  c  o m
        roadmap.add(p);
    }
    return roadmap;
}

From source file:com.coedil99.modello_di_dominio.impl.CommessaDAOImpl.java

public java.util.Iterator iterateCommessaByQuery(PersistentSession session, String condition, String orderBy)
        throws PersistentException {
    StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from   ww  w  . j  a 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:com.coedil99.modello_di_dominio.impl.CommessaDAOImpl.java

public java.util.Iterator iterateCommessaByQuery(PersistentSession session, String condition, String orderBy,
        org.hibernate.LockMode lockMode) throws PersistentException {
    StringBuffer sb = new StringBuffer("From com.coedil99.modello_di_dominio.Commessa as Commessa");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {//from  www.j a v a 2s  .c  o  m
        Query query = session.createQuery(sb.toString());
        query.setLockMode("Commessa", lockMode);
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}

From source file:com.coedil99.modello_di_dominio.impl.DescrizionePezzoDAOImpl.java

public java.util.Iterator iterateDescrizionePezzoByQuery(PersistentSession session, String condition,
        String orderBy) throws PersistentException {
    StringBuffer sb = new StringBuffer(
            "From com.coedil99.modello_di_dominio.DescrizionePezzo as DescrizionePezzo");
    if (condition != null)
        sb.append(" Where ").append(condition);
    if (orderBy != null)
        sb.append(" Order By ").append(orderBy);
    try {/*w  w w.j av  a2s. co  m*/
        Query query = session.createQuery(sb.toString());
        return query.iterate();
    } catch (Exception e) {
        e.printStackTrace();
        throw new PersistentException(e);
    }
}