Example usage for org.hibernate Query scroll

List of usage examples for org.hibernate Query scroll

Introduction

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

Prototype

ScrollableResults scroll();

Source Link

Document

Return the query results as ScrollableResults.

Usage

From source file:com.lp.server.rechnung.fastlanereader.GutschriftHandler.java

License:Open Source License

/**
 * sorts the data described by the current query using the specified sort
 * criterias. The current query is also updated with the new sort criterias.
 * //www.ja  v  a2  s . c o  m
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 * @throws EJBExceptionLP
 * @param sortierKriterien
 *            SortierKriterium[]
 * @param selectedId
 *            Object
 * @return QueryResult
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select gutschrift." + RechnungFac.FLR_RECHNUNG_I_ID
                    + " from FLRRechnung gutschrift " + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.GutschriftpositionsartHandler.java

License:Open Source License

/**
 * sorts the data of the current query using the specified criterias and
 * returns the page of data where the row of selectedId is contained.
 * //  w  w  w .j  av  a2  s. c  o m
 * @param sortierKriterien
 *            nach diesen Kriterien wird das Ergebnis sortiert
 * @param selectedId
 *            auf diesem Datensatz soll der Cursor stehen
 * @return QueryResult das Ergebnis der Abfrage
 * @throws EJBExceptionLP
 *             Ausnahme
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_GUTSCHRIFTPOSITIONSART
                    + RechnungFac.FLR_GUTSCHRIFTPOSITIONSART_POSITIONSART_C_NR
                    + FLR_GUTSCHRIFTPOSITIONSART_FROM_CLAUSE + this.buildWhereClause()
                    + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            session = setFilter(session);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    String c_nr = (String) scrollableResult.getString(0);
                    if (selectedId.equals(c_nr)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.GutschrifttextHandler.java

License:Open Source License

/**
 * sorts the data described by the current query using the specified sort
 * criterias. The current query is also updated with the new sort criterias.
 * /*from ww w. java2  s .c  om*/
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 * @throws EJBExceptionLP
 * @param sortierKriterien
 *            SortierKriterium[]
 * @param selectedId
 *            Object
 * @return QueryResult
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_GUTSCHRIFTTEXT + RechnungServiceFac.FLR_RECHNUNGTEXT_I_ID
                    + FLR_GUTSCHRIFTTEXT_FROM_CLAUSE + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            boolean idFound = false;
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.PositionHandler.java

License:Open Source License

/**
 * sorts the data described by the current query using the specified sort
 * criterias. The current query is also updated with the new sort criterias.
 * //w w w.j a v  a  2 s. c o  m
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 * @throws EJBExceptionLP
 * @param sortierKriterien
 *            SortierKriterium[]
 * @param selectedId
 *            Object
 * @return QueryResult
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select" + FLR_POSITION + RechnungFac.FLR_RECHNUNGPOSITION_I_ID
                    + FLR_POSITION_FROM_CLAUSE + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            closeSession(session);
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.ProformarechnungHandler.java

License:Open Source License

/**
 * sorts the data described by the current query using the specified sort
 * criterias. The current query is also updated with the new sort criterias.
 * //  w  ww. j  a  v a 2 s .c  o m
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 * @throws EJBExceptionLP
 * @param sortierKriterien
 *            SortierKriterium[]
 * @param selectedId
 *            Object
 * @return QueryResult
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select proformarechnung." + RechnungFac.FLR_RECHNUNG_I_ID
                    + " from FLRRechnung proformarechnung " + this.buildWhereClause()
                    + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.ProformarechnungpositionsartHandler.java

License:Open Source License

/**
 * sorts the data of the current query using the specified criterias and
 * returns the page of data where the row of selectedId is contained.
 * //from  w  ww . j  a  va  2s .c  o m
 * @param sortierKriterien
 *            nach diesen Kriterien wird das Ergebnis sortiert
 * @param selectedId
 *            auf diesem Datensatz soll der Cursor stehen
 * @return QueryResult das Ergebnis der Abfrage
 * @throws EJBExceptionLP
 *             Ausnahme
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_PROFORMARECHNUNGPOSITIONSART
                    + RechnungFac.FLR_PROFORMARECHNUNGPOSITIONSART_POSITIONSART_C_NR
                    + FLR_PROFORMARECHNUNGPOSITIONSART_FROM_CLAUSE + this.buildWhereClause()
                    + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            session = setFilter(session);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    String c_nr = (String) scrollableResult.getString(0);
                    if (selectedId.equals(c_nr)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.RechnungHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;/*from   www.j av a  2s.co  m*/
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select rechnung." + RechnungFac.FLR_RECHNUNG_I_ID
                    + " from FLRRechnung rechnung " + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            closeSession(session);
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.RechnungkontierungHandler.java

License:Open Source License

/**
 * sorts the data described by the current query using the specified sort
 * criterias. The current query is also updated with the new sort criterias.
 * /* w  w w  . jav a2s  .  co  m*/
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 * @throws EJBExceptionLP
 * @param sortierKriterien
 *            SortierKriterium[]
 * @param selectedId
 *            Object
 * @return QueryResult
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select arKontierung.i_id from FLRRechnungKontierung arKontierung "
                    + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    Integer id = (Integer) scrollableResult.getInteger(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.RechnungpositionsartHandler.java

License:Open Source License

/**
 * sorts the data of the current query using the specified criterias and
 * returns the page of data where the row of selectedId is contained.
 * //from  w w  w  .  j  ava 2s. co  m
 * @param sortierKriterien
 *            nach diesen Kriterien wird das Ergebnis sortiert
 * @param selectedId
 *            auf diesem Datensatz soll der Cursor stehen
 * @return QueryResult das Ergebnis der Abfrage
 * @throws EJBExceptionLP
 *             Ausnahme
 * @see UseCaseHandler#sort(SortierKriterium[], Object)
 */
public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;
    int rowNumber = 0;

    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_RECHNUNGPOSITIONSART
                    + RechnungFac.FLR_RECHNUNGPOSITIONSART_POSITIONSART_C_NR
                    + FLR_RECHNUNGPOSITIONSART_FROM_CLAUSE + this.buildWhereClause()
                    + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            // sprmapping2: 2c: filter setzen
            session = setFilter(session);

            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    String c_nr = (String) scrollableResult.getString(0);
                    if (selectedId.equals(c_nr)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}

From source file:com.lp.server.rechnung.fastlanereader.RechnungsartHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;/*from w  ww .  j a  va 2s.com*/
    int rowNumber = 0;

    // if (selectedId != null && ( (Integer) selectedId).intValue() >= 0) {
    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select rechnungart.c_nr from FLRRechnungart rechnungart "
                    + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    // Integer id = (Integer)
                    // scrollableResult.getInteger(0);
                    String id = (String) scrollableResult.getString(0);
                    if (selectedId.equals(id)) {
                        rowNumber = scrollableResult.getRowNumber();
                        break;
                    }
                }
            }
        } catch (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, e);
        } finally {
            try {
                session.close();
            } catch (HibernateException he) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he);
            }
        }
    }

    if (rowNumber < 0 || rowNumber >= this.getRowCount()) {
        rowNumber = 0;
    }

    result = this.getPageAt(new Integer(rowNumber));
    result.setIndexOfSelectedRow(rowNumber);

    return result;
}