Example usage for org.hibernate ScrollableResults next

List of usage examples for org.hibernate ScrollableResults next

Introduction

In this page you can find the example usage for org.hibernate ScrollableResults next.

Prototype

boolean next();

Source Link

Document

Advance to the next result.

Usage

From source file:com.lp.server.artikel.fastlanereader.InventurHandler.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 va  2  s .  com*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            String queryString = "select inventur.i_id from FLRInventur inventur " + 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.InventurlisteHandler.java

License:Open Source License

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

    QueryResult result = null;//from  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();
            session = setFilter(session);
            String queryString = this.getFromClause() + 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.InventurprotokollHandler.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 . ja  v a  2  s . 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 inventurprotokoll.i_id from FLRInventurprotokoll inventurprotokoll "
                    + 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.InventurstandHandler.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  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 inventurstand.i_id from FLRInventurstand inventurstand "
                    + 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.KatalogHandler.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  .  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 katalog.i_id from FLRKatalog katalog " + 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.KundenidentnummerHandler.java

License:Open Source License

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

    getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;//from   w w w .j a  v a 2s.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 = getFromClause() + buildWhereClause() + 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 {
                    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.LagercockpitArtikelHandler.java

License:Open Source License

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

    QueryResult result = null;/*from   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();
            session = setFilter(session);
            String queryString = "select artikellager.compId.artikel_i_id from FLRArtikellager artikellager LEFT OUTER JOIN artikellager.flrartikelliste.artikelsprset AS aspr "
                    + 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 (HibernateException 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.LagercockpitLossollmaterialHandler.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.java2 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_LOSMAT + FertigungFac.FLR_LOSSOLLMATERIAL_I_ID
                    + FLR_LOSMAT_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 {
            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.artikel.fastlanereader.LagercockpitNichtLagerbewirtschafteteArtikelHandler.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  ava  2 s.  c om*/
    int rowNumber = 0;

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

        try {
            session = factory.openSession();
            session = setFilter(session);
            String queryString = "select i_id from FLRWareneingangspositionen wep " + 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 (HibernateException 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.LagerGrunddatenHandler.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.ja  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 lager.i_id from FLRLager lager " + 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;
}