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.finanz.fastlanereader.MahnspesenHandler.java

License:Open Source License

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

    QueryResult result = null;/* ww  w  . ja  v a  2s . c  om*/
    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_MAHNSPESEN + FinanzFac.FLR_MAHNSTUFE_I_ID
                    + FLR_MAHNSPESEN_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 {
            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.finanz.fastlanereader.MahnstufeHandler.java

License:Open Source License

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

    QueryResult result = null;/*ww w .ja v  a 2  s.  c  o  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 " + FLR_MAHNSTUFE + FinanzFac.FLR_MAHNSTUFE_I_ID
                    + FLR_MAHNSTUFE_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 {
            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.finanz.fastlanereader.MahntextHandler.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  w  ww  . j a v  a  2  s  .  com
 * @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_MAHNTEXT + FinanzServiceFac.FLR_MAHNTEXT_I_ID
                    + FLR_MAHNTEXT_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, 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.finanz.fastlanereader.MahnungHandler.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   w  ww . jav  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 mahnung.i_id from FLRFinanzMahnung mahnung " + 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.finanz.fastlanereader.SteuerkategorieHandler.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 ava  2s . c  om*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_STEUERKATEGORIE + "i_id" + FLR_STEUERKATEGORIE_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 {
            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.finanz.fastlanereader.UvaartHandler.java

License:Open Source License

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

    QueryResult result = null;/*ww  w .  j av  a  2  s  . c om*/
    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 " + FLR_UVAART + "i_id" + FLR_UVAART_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 = 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, 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.finanz.fastlanereader.WarenverkehrsnummerHandler.java

License:Open Source License

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

    QueryResult result = null;/*from  ww w.j av a 2 s . c o m*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_WVKNR + FinanzServiceFac.FLR_WARENVERKEHRSNUMMER_C_NR
                    + FLR_WVKNR_FROM_CLAUSE + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    String id = scrollableResult.getString(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.inserat.fastlanereader.EingangsrechnungenEinesInseratesHandler.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  w  w  w.  j a  v  a 2s .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 flrinserater.i_id from FLRInserater as flrinserater left join flrinserater.flreingangsrechnung as eingangsrechnung  "
                    + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort as flrlandplzort "
                    + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort.flrort as flrort "
                    + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort.flrland as flrland  "
                    + 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.inserat.fastlanereader.InseratartikelHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    QueryResult result = null;/*from  www.  j  a  v  a2s  . c o m*/

    try {
        int rowNumber = 0;

        getQuery().setSortKrit(sortierKriterien);

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

            try {
                session = factory.openSession();
                String queryString = "select " + FLR_INSERATARTIKEL + "i_id" + FLR_INSERATARTIKEL_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;
                        }
                    }
                }
            } finally {
                try {
                    session.close();
                } catch (HibernateException he) {
                    throw new EJBExceptionLP(EJBExceptionLP.FEHLER_HIBERNATE, he);
                }
            }
        }

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

        result = this.getPageAt(new Integer(rowNumber));
        result.setIndexOfSelectedRow(rowNumber);
    } catch (Exception ex) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER, ex);
    }

    return result;
}

From source file:com.lp.server.inserat.fastlanereader.InserateOhneERHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    QueryResult result = null;/*from   w w  w  .ja  v  a2 s  . c  o m*/

    try {
        int rowNumber = 0;

        getQuery().setSortKrit(sortierKriterien);

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

            try {
                session = factory.openSession();
                String queryString = "select flrinserat.i_id  from FLRInserat flrinserat LEFT OUTER JOIN flrinserat.erset as erset left outer join flrinserat.rechnungset re WHERE re.i_sort=1 "
                        + 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;
                        }
                    }
                }
            } finally {
                try {
                    session.close();
                } catch (HibernateException he) {
                    throw new EJBExceptionLP(EJBExceptionLP.FEHLER_HIBERNATE, he);
                }
            }
        }

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

        result = this.getPageAt(new Integer(rowNumber));
        result.setIndexOfSelectedRow(rowNumber);
    } catch (Exception ex) {
        throw new EJBExceptionLP(EJBExceptionLP.FEHLER, ex);
    }

    return result;
}