List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.benutzer.fastlanereader.LagerrolleHandler.java
License:Open Source License
/** * The information needed for the kundes table. * /*w w w .j a v a 2 s. c o m*/ * @param rowIndex * Integer * @throws EJBExceptionLP * @return QueryResult */ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); session = setFilter(session); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRLagerrolle artikelkommentarart = (FLRLagerrolle) resultListIterator.next(); rows[row][col++] = artikelkommentarart.getI_id(); rows[row][col++] = artikelkommentarart.getFlrlager().getC_nr(); rows[row][col++] = artikelkommentarart.getFlrlager().getMandant_c_nr(); row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.NachrichtarchivHandler.java
License:Open Source License
/** * The information needed for the kundes table. *///from w ww . j a v a 2 s . c o m public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int startIndex = Math.max(rowIndex.intValue() - (PAGE_SIZE / 2), 0); int endIndex = startIndex + PAGE_SIZE - 1; session = factory.openSession(); String queryString = this.getFromClause() + " " + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(PAGE_SIZE); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; String[] tooltipData = new String[resultList.size()]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { Object[] o = (Object[]) resultListIterator.next(); FLRNachrichtarchiv nachrichtarchiv = (FLRNachrichtarchiv) o[0]; rows[row][col++] = nachrichtarchiv.getI_id(); rows[row][col++] = nachrichtarchiv.getFlrnachrichtart().getC_nr(); rows[row][col++] = nachrichtarchiv.getC_nachricht(); String erzeuger = nachrichtarchiv.getFlrpersonal_anlegen().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (nachrichtarchiv.getFlrpersonal_anlegen().getFlrpartner() .getC_name2vornamefirmazeile2() != null) { erzeuger += " " + nachrichtarchiv.getFlrpersonal_anlegen().getFlrpartner() .getC_name2vornamefirmazeile2(); } rows[row][col++] = erzeuger; rows[row][col++] = nachrichtarchiv.getT_zeit(); String bearbeiter = null; if (nachrichtarchiv.getFlrpersonal_bearbeiter() != null) { bearbeiter = nachrichtarchiv.getFlrpersonal_bearbeiter().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (nachrichtarchiv.getFlrpersonal_bearbeiter().getFlrpartner() .getC_name2vornamefirmazeile2() != null) { bearbeiter += " " + nachrichtarchiv.getFlrpersonal_bearbeiter().getFlrpartner() .getC_name2vornamefirmazeile2(); } } rows[row][col++] = bearbeiter; rows[row][col++] = nachrichtarchiv.getT_bearbeitung(); String erlediger = null; if (nachrichtarchiv.getFlrpersonal_erledigt() != null) { erlediger = nachrichtarchiv.getFlrpersonal_erledigt().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (nachrichtarchiv.getFlrpersonal_erledigt().getFlrpartner() .getC_name2vornamefirmazeile2() != null) { erlediger += " " + nachrichtarchiv.getFlrpersonal_erledigt().getFlrpartner() .getC_name2vornamefirmazeile2(); } } tooltipData[row] = nachrichtarchiv.getC_erledigungsgrund(); rows[row][col++] = erlediger; rows[row++][col++] = nachrichtarchiv.getT_erledigt(); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0, tooltipData); } catch (HibernateException e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.NachrichtartHandler.java
License:Open Source License
/** * The information needed for the kundes table. *//*from w w w .j a v a 2s. c o m*/ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int startIndex = Math.max(rowIndex.intValue() - (PAGE_SIZE / 2), 0); int endIndex = startIndex + PAGE_SIZE - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(PAGE_SIZE); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRNachrichtart nachrichtenart = (FLRNachrichtart) resultListIterator.next(); rows[row][col++] = nachrichtenart.getI_id(); rows[row][col++] = nachrichtenart.getC_nr(); rows[row][col++] = nachrichtenart.getC_bez(); rows[row][col++] = nachrichtenart.getFlrthema().getC_nr(); rows[row][col++] = new Boolean(Helper.short2Boolean(nachrichtenart.getB_archivieren())); rows[row++][col++] = new Boolean(Helper.short2Boolean(nachrichtenart.getB_popup())); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (HibernateException e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.RechtHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w. j a va2s . c o m SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRRecht recht = (FLRRecht) resultListIterator.next(); rows[row][col++] = recht.getC_nr(); rows[row][col++] = recht.getC_nr().trim(); rows[row++][col++] = recht.getX_kommentar(); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (HibernateException e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.RollerechtHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w ww . jav a 2 s . c om SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRRollerecht kollektiv = (FLRRollerecht) resultListIterator.next(); rows[row][col++] = kollektiv.getI_id(); rows[row][col++] = kollektiv.getFlrrecht().getC_nr().trim(); rows[row++][col++] = kollektiv.getFlrrecht().getX_kommentar(); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (HibernateException e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.SystemrolleHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// ww w .ja v a 2 s .c om SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRSystemrolle systemrolle = (FLRSystemrolle) resultListIterator.next(); rows[row][col++] = systemrolle.getI_id(); rows[row++][col++] = systemrolle.getC_bez(); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (HibernateException e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.ThemaHandler.java
License:Open Source License
/** * The information needed for the kundes table. * /*from w w w. jav a2 s. c o m*/ * @param rowIndex * Integer * @throws EJBExceptionLP * @return QueryResult */ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); session = setFilter(session); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRThema thema = (FLRThema) resultListIterator.next(); rows[row][col++] = thema.getC_nr(); rows[row][col++] = thema.getC_nr(); rows[row][col++] = thema.getC_bez(); row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he); } } return result; }
From source file:com.lp.server.benutzer.fastlanereader.ThemarolleHandler.java
License:Open Source License
/** * The information needed for the kundes table. * //from w w w . j av a 2 s.c o m * @param rowIndex * Integer * @throws EJBExceptionLP * @return QueryResult */ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); session = setFilter(session); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRThemarolle artikelkommentarart = (FLRThemarolle) resultListIterator.next(); rows[row][col++] = artikelkommentarart.getI_id(); rows[row][col++] = artikelkommentarart.getFlrthema().getC_nr(); rows[row][col++] = artikelkommentarart.getFlrsystemrolle().getC_bez(); row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he); } } return result; }
From source file:com.lp.server.bestellung.fastlanereader.BestellpositionartHandler.java
License:Open Source License
/** * gets the page of data for the specified row using the current * queryParameters./*from w w w. j a v a2 s . c o m*/ * * @param rowIndex * diese Zeile soll selektiert sein * @return QueryResult das Ergebnis der Abfrage * @throws EJBExceptionLP * Ausnahme * @see UseCaseHandler#getPageAt(java.lang.Integer) */ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = BestellpositionartHandler.PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRBestellpositionart positionart = (FLRBestellpositionart) resultListIterator.next(); rows[row][col++] = positionart.getPositionsart_c_nr(); rows[row][col++] = getSystemMultilanguageFac().uebersetzePositionsartOptimal( positionart.getPositionsart_c_nr(), theClientDto.getLocUi(), theClientDto.getLocMandant()); rows[row][col++] = positionart.getI_sort(); row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { closeSession(session); } return result; }
From source file:com.lp.server.bestellung.fastlanereader.Bestellpositionhandler.java
License:Open Source License
/** * gets the page of data for the specified row using the current * queryParameters./*w ww. ja v a 2s .c o m*/ * * @param rowIndex * the index of the row that should be contained in the page. * @return the data page for the specified row. * @throws EJBExceptionLP */ public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null; SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; String mandantCNr = theClientDto.getMandant(); Locale locUI = theClientDto.getLocUi(); try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = BestellungHandler.PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = this.getFromClause() + this.buildWhereClause() + this.buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); Object[][] rows = new Object[resultList.size()][colCount]; String[] tooltipData = new String[resultList.size()]; int row = 0; int col = 0; // darf Preise sehen. final boolean bDarfPreiseSehen = getTheJudgeFac().hatRecht(RechteFac.RECHT_LP_DARF_PREISE_SEHEN_EINKAUF, theClientDto); int iNachkommastellenMenge = getMandantFac().getNachkommastellenMenge(mandantCNr); int iNachkommastellenPreis = getMandantFac().getNachkommastellenPreisEK(mandantCNr); BestellungDto bestDto = null; while (resultListIterator.hasNext()) { FLRBestellposition position = (FLRBestellposition) resultListIterator.next(); rows[row][col++] = position.getI_id(); rows[row][col++] = getBestellpositionFac().getPositionNummerReadOnly(position.getI_id()); rows[row][col++] = getUIObjectBigDecimalNachkommastellen(position.getN_menge(), iNachkommastellenMenge); if (position.getEinheit_c_nr() != null) { rows[row][col++] = position.getEinheit_c_nr().trim(); } else { rows[row][col++] = position.getEinheit_c_nr(); } String sIdentnummer = ""; if (position.getFlrartikel() != null) { sIdentnummer = position.getFlrartikel().getC_nr(); } rows[row][col++] = sIdentnummer; // in der Spalte Bezeichnung koennen verschiedene Dinge stehen String sBezeichnung = null; if (position.getBestellpositionart_c_nr().equals(LocaleFac.POSITIONSART_TEXTEINGABE)) { if (position.getC_textinhalt() != null && position.getC_textinhalt().length() > 0) { sBezeichnung = Helper.strippHTML(position.getC_textinhalt()); } } else if (position.getBestellpositionart_c_nr().equals(LocaleFac.POSITIONSART_SEITENUMBRUCH)) { sBezeichnung = "[" + getTextRespectUISpr("lp.seitenumbruch", mandantCNr, locUI) + "]"; } else if (position.getBestellpositionart_c_nr().equals(LocaleFac.POSITIONSART_TEXTBAUSTEIN)) { sBezeichnung = position.getFlrmediastandard().getC_nr(); } else if (position.getBestellpositionart_c_nr().equals(LocaleFac.POSITIONSART_IDENT)) { // die sprachabhaengig Artikelbezeichnung anzeigen sBezeichnung = getArtikelFac().formatArtikelbezeichnungEinzeiligOhneExc( position.getFlrartikel().getI_id(), theClientDto.getLocUi()); } else { // die uebersteuerte bezeichnung if (position.getC_bezeichnung() != null) { sBezeichnung = position.getC_bezeichnung(); } } rows[row][col++] = sBezeichnung; boolean bPreisOK = true; if (bDarfPreiseSehen) { if (bPreisueberwachung && position.getFlrartikel() != null) { if (bestDto == null) { bestDto = getBestellungFac() .bestellungFindByPrimaryKey(position.getFlrbestellung().getI_id()); } ArtikellieferantDto alDto = getArtikelFac().getArtikelEinkaufspreis( position.getFlrartikel().getI_id(), bestDto.getLieferantIIdBestelladresse(), position.getN_menge(), bestDto.getWaehrungCNr(), bestDto.getDBelegdatum(), theClientDto); if (alDto != null && alDto.getNNettopreis() != null) { if (!Helper.rundeKaufmaennisch(alDto.getNNettopreis(), iNachkommastellenPreis) .equals(Helper.rundeKaufmaennisch(position.getN_nettogesamtpreis(), iNachkommastellenPreis))) { bPreisOK = false; } } } if (position.getN_nettogesamtpreis() == null || position.getN_menge() == null) { rows[row][col++] = null; rows[row][col++] = null; } else { rows[row][col++] = getUIObjectBigDecimalNachkommastellen(position.getN_nettogesamtpreis(), iNachkommastellenPreis); rows[row][col++] = getUIObjectBigDecimalNachkommastellen( position.getN_nettogesamtpreis().multiply(position.getN_menge()), iNachkommastellenPreis); } } else { rows[row][col++] = null; rows[row][col++] = null; } rows[row][col++] = position.getBestellpositionstatus_c_nr(); // Text if (position.getC_textinhalt() != null && !position.getC_textinhalt().equals("")) { rows[row][col++] = new Boolean(true); String text = position.getC_textinhalt(); text = text.replaceAll("\n", "<br>"); text = "<html>" + text + "</html>"; tooltipData[row] = text; } else { rows[row][col++] = new Boolean(false); } if (bPreisOK == false) { rows[row][col++] = Color.RED; } row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0, tooltipData); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, e); } finally { closeSession(session); } return result; }