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.artikel.fastlanereader.ArtikelkommentarartHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {

    getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;/*from ww w . ja v a2 s. c om*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            session = setFilter(session);
            String queryString = getFromClause() + buildWhereClause() + buildOrderByClause();

            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    FLRArtikelkommentarart artikelkommentarart = (FLRArtikelkommentarart) scrollableResult
                            .get(0);
                    Integer iId = artikelkommentarart.getI_id();
                    if (selectedId.equals(iId)) {
                        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.artikel.fastlanereader.ArtikelkommentarHandler.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  a2  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 flrartikelkommentar.i_id from FLRArtikelkommentar flrartikelkommentar "
                    + 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); // TYPE
                    // OF
                    // KEY
                    // ATTRIBUTE
                    // !
                    // !
                    // !
                    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.artikel.fastlanereader.ArtikellagerHandler.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 v a2  s.  c o  m*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select artikellager." + LagerFac.FLR_ARTIKELLAGER_ARTIKEL_I_ID
                    + " from FLRArtikellager artikellager " + 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.get(0); //
                    // TYPE OF KEY ATTRIBUTE !!!
                    // 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.artikel.fastlanereader.ArtikellagerplaetzeHandler.java

License:Open Source License

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

    QueryResult result = null;//  w w w.j a  va  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 artikellagerplaetze.i_id from FLRArtikellagerplaetze artikellagerplaetze "
                    + 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); // TYPE
                    // OF
                    // KEY
                    // ATTRIBUTE
                    // !
                    // !
                    // !
                    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.artikel.fastlanereader.ArtikellieferantHandler.java

License:Open Source License

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

    QueryResult result = null;/*from   w  w w .  j a v a 2s  .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 artikellieferant.i_id from FLRArtikellieferant artikellieferant "
                    + 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); // TYPE
                    // OF
                    // KEY
                    // ATTRIBUTE
                    // !
                    // !
                    // !
                    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.artikel.fastlanereader.ArtikellieferantstaffelHandler.java

License:Open Source License

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

    QueryResult result = null;/* www .j a  v a 2 s .  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 artikellieferantstaffel.i_id from FLRArtikellieferantstaffel artikellieferantstaffel "
                    + 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); // TYPE
                    // OF
                    // KEY
                    // ATTRIBUTE
                    // !
                    // !
                    // !
                    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.artikel.fastlanereader.ArtikellisteHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedIdI) throws EJBExceptionLP {

    getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;//from www . j a  v a2  s  .c o m
    int rowNumber = 0;
    ScrollableResults scrollableResult = null;
    if (selectedIdI instanceof Integer) {
        if (selectedIdI != null && ((Integer) selectedIdI).intValue() >= 0) {
            SessionFactory factory = FLRSessionFactory.getFactory();
            Session session = null;

            try {
                session = factory.openSession();
                session = setFilter(session);

                String queryString = null;
                try {

                    queryString = "SELECT artikelliste.i_id FROM FLRArtikelliste AS artikelliste LEFT OUTER JOIN artikelliste.artikellagerset AS alager "
                            + " LEFT OUTER JOIN artikelliste.flrgeometrie AS geo "
                            + " LEFT OUTER JOIN artikelliste.stuecklisten AS stuecklisten "
                            + " LEFT OUTER JOIN artikelliste.artikellieferantset AS artikellieferantset "
                            + " LEFT OUTER JOIN artikelliste.artikelsprset AS aspr "
                            + " LEFT OUTER JOIN artikelliste.flrartikelgruppe AS ag "
                            + " LEFT OUTER JOIN artikelliste.flrartikelklasse AS ak " + buildWhereClause()
                            + buildGroupByClause() + buildOrderByClause();
                } catch (Exception ex) {
                    throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, ex);
                }

                Query query = session.createQuery(queryString);
                scrollableResult = query.scroll();

                if (scrollableResult != null) {
                    scrollableResult.beforeFirst();
                    while (scrollableResult.next()) {
                        Integer id = (Integer) scrollableResult.getInteger(0);
                        if (selectedIdI.equals(id)) {
                            rowNumber = scrollableResult.getRowNumber();
                            break;
                        }
                    }
                }
            } catch (HibernateException e) {
                throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e);
            } finally {
                try {
                    if (session != null)
                        session.close();
                } catch (HibernateException he) {
                    throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he);
                }
            }
        }
    }
    if (rowNumber < 0
    // || rowNumber >= getRowCount()
    ) {
        rowNumber = 0;
    }

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

    return result;
}

From source file:com.lp.server.artikel.fastlanereader.ArtikelreservierungHandler.java

License:Open Source License

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

    QueryResult result = null;//  ww w.  j a  v a2s . c om
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select artikelreservierung."
                    + ReservierungFac.FLR_ARTIKELRESERVIERUNG_C_BELEGARTNR
                    + " from FLRArtikelreservierung artikelreservierung " + this.buildWhereClause()
                    + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    String id = (String) scrollableResult.getString(0); // TYPE
                    // OF
                    // KEY
                    // ATTRIBUTE
                    // !
                    // !
                    // !
                    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.artikel.fastlanereader.ArtikelshopgruppeHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {

    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;//from w  w  w . j  av a 2 s. c  om
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select artikelshopgruppe.i_id from FLRArtikelshopgruppe artikelshopgruppe "
                    + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    if (selectedId.equals(scrollableResult.get(0))) {
                        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.artikel.fastlanereader.ArtikelsperrenHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {

    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;//w w w  .ja  v  a  2  s .com
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select artikelsperren.i_id from FLRArtikelsperren artikelsperren "
                    + this.buildWhereClause() + this.buildOrderByClause();
            Query query = session.createQuery(queryString);
            ScrollableResults scrollableResult = query.scroll();
            if (scrollableResult != null) {
                scrollableResult.beforeFirst();
                while (scrollableResult.next()) {
                    if (selectedId.equals(scrollableResult.get(0))) {
                        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;
}