Example usage for org.hibernate ScrollableResults beforeFirst

List of usage examples for org.hibernate ScrollableResults beforeFirst

Introduction

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

Prototype

void beforeFirst();

Source Link

Document

Go to a location just before first result, This is the location of the cursor on a newly returned scrollable result.

Usage

From source file:com.lp.server.bestellung.fastlanereader.BestellvorschlagAlleTermineHandler.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 a 2s. 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) {
    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select bestellvorschlagalletermine." + "t_liefertermin"
                    + " from FLRBestellvorschlagAlleTermine bestellvorschlagalletermine "
                    + 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 {
            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.bestellung.fastlanereader.BestellvorschlagHandler.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.
 * // ww  w . ja  va2  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) {
    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select bestellvorschlag." + "i_id"
                    + " from FLRBestellvorschlag bestellvorschlag  LEFT OUTER JOIN bestellvorschlag.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 (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, 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.bestellung.fastlanereader.BSMahnlaufHandler.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  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 bsmahnlauf.i_id from FLRBSMahnlauf bsmahnlauf "
                    + 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.bestellung.fastlanereader.BSMahnstufeHandler.java

License:Open Source License

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

    QueryResult result = null;/*ww  w  . jav 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 " + FLR_MAHNSTUFE + BSMahnwesenFac.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 {
            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.bestellung.fastlanereader.BSMahntextHandler.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.
 * /*ww  w.  j av a  2 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_MAHNTEXT + BSMahnwesenFac.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 {
            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.bestellung.fastlanereader.BSMahnungHandler.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  . ja  v  a  2  s  .  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 bsmahnung.i_id from FLRBSMahnung bsmahnung " + 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.bestellung.fastlanereader.LieferantenoptimierenHandler.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 .  ja 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) {
    if (selectedId != null) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select flrLieferantenoptimieren." + "bestellvorschlag_i_id"
                    + " from FLRLieferantenoptimieren flrLieferantenoptimieren  LEFT OUTER JOIN flrLieferantenoptimieren.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 (Exception e) {
            throw new EJBExceptionLP(EJBExceptionLP.FEHLER, 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.bestellung.fastlanereader.MahngruppeHandler.java

License:Open Source License

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

    this.getQuery().setSortKrit(sortierKriterien);

    QueryResult result = null;//w  ww  . ja  va  2 s .c o  m
    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()) {
                    FLRMahngruppe status = (FLRMahngruppe) scrollableResult.get(0);
                    Integer artgruIId = status.getArtgru_i_id();
                    if (selectedId.equals(artgruIId)) {
                        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.bestellung.fastlanereader.NichtMehrBenoetigteBestellungenHandler.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  .j ava2  s.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 {
    final String METHOD_NAME = "sort";

    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 wareneingang." + "i_id" + " from FLRWareneingang wareneingang "
                    + 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 {
            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.bestellung.fastlanereader.OffeneWEPosHandler.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  www . j a  va2 s .  c o m*/
 * @param sortierKriterien
 *            the new sort criterias.
 * @param selectedId
 *            the id of the entity that should be included in the result
 *            page.
 * @return the sorted data containing the page where the entity with the
 *         specified id is located.
 * @throws EJBExceptionLP
 */
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();
            session = setFilter(session);
            String queryString = "select position." + "i_id"
                    + " from FLRBestellpositionMitArtikelliste position LEFT OUTER JOIN position.flrartikel.artikelsprset AS aspr "
                    + 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_FLR, e);
        } finally {
            closeSession(session);
        }
    }

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

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

    return result;
}