Example usage for org.hibernate ScrollableResults getRowNumber

List of usage examples for org.hibernate ScrollableResults getRowNumber

Introduction

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

Prototype

int getRowNumber();

Source Link

Document

Get the current position in the results.

Usage

From source file:com.lp.server.auftrag.fastlanereader.AuftragEingangsrechnungenHandler.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  . 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 er.i_id from FLREingangsrechnungAuftragszuordnung er "
                    + 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.auftrag.fastlanereader.AuftragHandler.java

License:Open Source License

public QueryResult sort(SortierKriterium[] sortierKriterien, Object selectedId) throws EJBExceptionLP {
    QueryResult result = null;//from   ww w. j av  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 " + FLR_AUFTRAG + AuftragFac.FLR_AUFTRAG_I_ID
                        + FLR_AUFTRAG_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.auftrag.fastlanereader.AuftragpositionartHandler.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  a v a 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_AUFTRAGPOSITIONART
                    + AuftragServiceFac.FLR_AUFTRAGPOSITIONART_POSITIONSART_C_NR
                    + FLR_AUFTRAGPOSITIONART_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.auftrag.fastlanereader.AuftragpositionHandler.java

License:Open Source License

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

    QueryResult result = null;/* w ww. 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_AUFTRAGPOSITION + "i_id" + FLR_AUFTRAGPOSITION_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.auftrag.fastlanereader.AuftragpositionSichtRahmenHandler.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 .  java  2  s.  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 {
    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_AUFTRAGPOSITIONSICHTRAHMEN + "i_id"
                    + FLR_AUFTRAGPOSITIONSICHTRAHMEN_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.auftrag.fastlanereader.AuftragseriennrnHandler.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  va2  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 flrauftragseriennrn.i_id"
                    + " from FLRAuftragseriennrn flrauftragseriennrn " + 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.auftrag.fastlanereader.AuftragteilnehmerHandler.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 .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 " + FLR_AUFTRAGTEILNEHMER
                    + AuftragteilnehmerFac.FLR_AUFTRAGTEILNEHMER_I_ID + FLR_AUFTRAGTEILNEHMER_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.auftrag.fastlanereader.AuftragtextHandler.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  av a 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 && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_AUFTRAGTEXT + AuftragServiceFac.FLR_AUFTRAGTEXT_I_ID
                    + FLR_AUFTRAGTEXT_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.auftrag.fastlanereader.PositionenSichtAuftragHandler.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 ava2 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 && ((Integer) selectedId).intValue() >= 0) {
        SessionFactory factory = FLRSessionFactory.getFactory();
        Session session = null;

        try {
            session = factory.openSession();
            String queryString = "select " + FLR_POSITIONENSICHTAUFTRAG
                    + AuftragpositionFac.FLR_AUFTRAGPOSITIONSICHTAUFTRAG_I_ID
                    + FLR_POSITIONENSICHTAUFTRAG_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.benutzer.fastlanereader.BenutzerHandler.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 va2 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 benutzer.i_id from FLRBenutzer benutzer " + 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;
}