List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.finanz.fastlanereader.UvaartHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w .j ava2 s . co 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; Locale locUI = theClientDto.getLocUi(); while (resultListIterator.hasNext()) { FLRFinanzUVAArt uva = (FLRFinanzUVAArt) resultListIterator.next(); rows[row][col++] = uva.getI_id(); rows[row][col++] = uva.getC_nr(); rows[row][col++] = uva.getC_kennzeichen(); rows[row][col++] = getFinanzServiceFac().uebersetzeUvaartOptimal(uva.getI_id(), locUI, locUI); 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.finanz.fastlanereader.WarenverkehrsnummerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w . ja v a 2 s. c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = 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; while (resultListIterator.hasNext()) { int col = 0; FLRFinanzWarenverkehrsnummer intbest = (FLRFinanzWarenverkehrsnummer) resultListIterator.next(); rows[row][col++] = intbest.getC_nr(); rows[row][col++] = intbest.getC_nr(); rows[row][col++] = intbest.getC_bez(); row++; } 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.inserat.fastlanereader.EingangsrechnungenEinesInseratesHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * //from w ww. j av a2 s . c o m * @see UseCaseHandler#getPageAt(java.lang.Integer) * @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 = 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 = "SELECT flrinserater,(SELECT count(*) FROM FLRFinanzBelegbuchung as bb WHERE bb.belegart_c_nr='" + LocaleFac.BELEGART_EINGANGSRECHNUNG + "' AND bb.i_belegiid=eingangsrechnung.i_id ) from FLRInserater as flrinserater left join flrinserater.flreingangsrechnung as eingangsrechnung " + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort as flrlandplzort " + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort.flrort as flrort " + " left join eingangsrechnung.flrlieferant.flrpartner.flrlandplzort.flrland as flrland " + 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()) { // ortimhandler: 8 da kommt jetzt ein Array zurueck, das an // index 0 brauch ich Object[] o = (Object[]) resultListIterator.next(); FLRInserater inserater = (FLRInserater) o[0]; FLREingangsrechnung eingangsrechnung = inserater.getFlreingangsrechnung(); long lVerbucht = (Long) o[1]; rows[row][col++] = eingangsrechnung.getI_id(); rows[row][col++] = eingangsrechnung.getEingangsrechnungart_c_nr() == null ? null : eingangsrechnung.getEingangsrechnungart_c_nr().substring(0, 1); rows[row][col++] = eingangsrechnung.getC_nr(); rows[row][col++] = eingangsrechnung.getFlrlieferant().getFlrpartner() .getC_name1nachnamefirmazeile1(); // ortimhandler: 1 wenn vorhanden, dann im Format A-5020 // Salzburg FLRLandplzort anschrift = eingangsrechnung.getFlrlieferant().getFlrpartner().getFlrlandplzort(); if (anschrift != null) { rows[row][col++] = anschrift.getFlrland().getC_lkz() + "-" + anschrift.getC_plz() + " " + anschrift.getFlrort().getC_name(); } else { rows[row][col++] = ""; } rows[row][col++] = eingangsrechnung.getT_belegdatum(); String sStatus = eingangsrechnung.getStatus_c_nr(); if (eingangsrechnung.getT_gedruckt() != null) { rows[row][col++] = getStatusMitUebersetzung(sStatus, eingangsrechnung.getT_gedruckt(), "DRUCKER"); } else { rows[row][col++] = getStatusMitUebersetzung(sStatus); } String lrnText = ""; if (eingangsrechnung.getC_lieferantenrechnungsnummer() != null) { lrnText = eingangsrechnung.getC_lieferantenrechnungsnummer(); if (eingangsrechnung.getC_text() != null) { lrnText = lrnText + " " + eingangsrechnung.getC_text(); } } else if (eingangsrechnung.getC_text() != null) { lrnText = eingangsrechnung.getC_text(); } else { lrnText = ""; } rows[row][col++] = lrnText; rows[row][col++] = inserater.getN_betrag(); rows[row][col++] = eingangsrechnung.getWaehrung_c_nr(); if (bHatFibu == true) { if (lVerbucht > 0) { rows[row][col++] = new Boolean(true); } else { rows[row][col++] = new Boolean(false); } } else { rows[row][col++] = new Boolean(eingangsrechnung.getT_fibuuebernahme() != null); } row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (RemoteException ex) { throwEJBExceptionLPRespectOld(ex); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FLR, he); } } return result; }
From source file:com.lp.server.inserat.fastlanereader.InseratartikelHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * /*w w w .j a v a2s. 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 = 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()) { FLRInseratartikel inserat = (FLRInseratartikel) resultListIterator.next(); rows[row][col++] = inserat.getI_id(); rows[row][col++] = inserat.getFlrartikel().getC_nr(); ArtikelDto aDto = getArtikelFac().artikelFindByPrimaryKeySmall(inserat.getFlrartikel().getI_id(), theClientDto); rows[row][col++] = aDto.formatBezeichnung(); rows[row][col++] = inserat.getN_menge(); rows[row][col++] = inserat.getN_nettoeinzelpreis_ek(); rows[row][col++] = inserat.getN_nettoeinzelpreis_vk(); if (inserat.getFlrbestellposition() != null) { rows[row][col++] = inserat.getFlrbestellposition().getFlrbestellung().getC_nr(); } else { rows[row][col++] = null; } 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.inserat.fastlanereader.InserateOhneERHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * /*w w w. j a v a 2 s . com*/ * @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 = 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; // darf Preise sehen. final boolean bDarfPreiseSehen = getTheJudgeFac().hatRecht(RechteFac.RECHT_LP_DARF_PREISE_SEHEN_VERKAUF, theClientDto); while (resultListIterator.hasNext()) { FLRInserat inserat = (FLRInserat) resultListIterator.next(); FLRInseratrechnung inseratrechnung = null; Set s = inserat.getRechnungset(); if (s.size() > 0) { inseratrechnung = (FLRInseratrechnung) s.iterator().next(); } rows[row][col++] = inserat.getI_id(); rows[row][col++] = inserat.getC_nr(); if (inseratrechnung != null) { rows[row][col++] = inseratrechnung.getFlrkunde().getFlrpartner().getC_kbez(); } else { rows[row][col++] = null; } rows[row][col++] = inserat.getT_belegdatum(); rows[row][col++] = inserat.getC_stichwort(); rows[row][col++] = inserat.getFlrlieferant().getFlrpartner().getC_kbez(); rows[row][col++] = inserat.getT_termin(); rows[row][col++] = inserat.getFlrartikel_inseratart().getC_nr(); if (inserat.getFlrbestellposition() != null) { rows[row][col++] = inserat.getFlrbestellposition().getFlrbestellung().getC_nr(); } else { rows[row][col++] = null; } if (inserat.getT_erschienen() != null) { rows[row][col++] = Boolean.TRUE; } else { rows[row][col++] = Boolean.FALSE; } rows[row][col++] = inserat.getN_menge(); if (bDarfPreiseSehen) { rows[row][col++] = inserat.getN_nettoeinzelpreis_ek(); } else { rows[row][col++] = null; } if (inseratrechnung != null && inseratrechnung.getFlrrechnungposition() != null) { rows[row][col++] = inseratrechnung.getFlrrechnungposition().getFlrrechnung().getC_nr(); } else { rows[row][col++] = null; } Set sEr = inserat.getErset(); if (sEr.size() > 0) { FLRInserater inserater = (FLRInserater) sEr.iterator().next(); rows[row][col++] = inserater.getFlreingangsrechnung().getC_nr(); } else { rows[row][col++] = null; } 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.inserat.fastlanereader.InseraterHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * //from ww w .j av a 2 s.c om * @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 = 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()) { FLRInserater inserat = (FLRInserater) resultListIterator.next(); rows[row][col++] = inserat.getI_id(); rows[row][col++] = inserat.getFlreingangsrechnung().getC_nr(); rows[row][col++] = inserat.getFlrinserat().getC_nr(); FLRInseratrechnung inseratrechnung = null; Set s = inserat.getFlrinserat().getRechnungset(); if (s.size() > 0) { inseratrechnung = (FLRInseratrechnung) s.iterator().next(); } if (inseratrechnung != null) { rows[row][col++] = inseratrechnung.getFlrkunde().getFlrpartner().getC_kbez(); } else { rows[row][col++] = null; } rows[row][col++] = inserat.getN_betrag(); rows[row][col++] = getInseratFac() .berechneWerbeabgabeLFEinesInserates(inserat.getFlrinserat().getI_id(), theClientDto); if (inserat.getFlrinserat().getArtikelset().size() > 0) { rows[row][col++] = "A"; } else { rows[row][col++] = null; } rows[row][col++] = inserat.getC_text(); 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.inserat.fastlanereader.InseratHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * //from w w w. j a v a 2s . c om * @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 = 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; String[] tooltipData = new String[resultList.size()]; // darf Preise sehen. final boolean bDarfPreiseSehen = getTheJudgeFac().hatRecht(RechteFac.RECHT_LP_DARF_PREISE_SEHEN_VERKAUF, theClientDto); while (resultListIterator.hasNext()) { FLRInserat inserat = (FLRInserat) resultListIterator.next(); FLRInseratrechnung inseratrechnung = null; Set s = inserat.getRechnungset(); String subStatusBezahlt = null; if (inserat.getC_nr().equals("13/M000738")) { int u = 0; } if (s.size() > 0) { Iterator it = s.iterator(); boolean bAlleBezahlt = true; while (it.hasNext()) { FLRInseratrechnung ir = (FLRInseratrechnung) it.next(); if (inseratrechnung == null) { inseratrechnung = ir; } if (ir.getFlrrechnungposition() == null || !ir.getFlrrechnungposition().getFlrrechnung() .getStatus_c_nr().equals(RechnungFac.STATUS_BEZAHLT)) { bAlleBezahlt = false; } if (ir.getFlrrechnungposition() != null && ir.getFlrrechnungposition().getFlrrechnung() .getStatus_c_nr().equals(RechnungFac.STATUS_TEILBEZAHLT)) { subStatusBezahlt = RechnungFac.STATUS_TEILBEZAHLT; break; } } if (bAlleBezahlt == true) { subStatusBezahlt = RechnungFac.STATUS_BEZAHLT; } } rows[row][col++] = inserat.getI_id(); rows[row][col++] = inserat.getC_nr(); if (inseratrechnung != null) { rows[row][col++] = inseratrechnung.getFlrkunde().getFlrpartner().getC_kbez(); } else { rows[row][col++] = null; } rows[row][col++] = inserat.getT_belegdatum(); rows[row][col++] = inserat.getC_stichwort(); rows[row][col++] = inserat.getFlrlieferant().getFlrpartner().getC_kbez(); rows[row][col++] = inserat.getT_termin(); rows[row][col++] = inserat.getFlrartikel_inseratart().getC_nr(); if (inserat.getFlrbestellposition() != null) { rows[row][col++] = inserat.getFlrbestellposition().getFlrbestellung().getC_nr(); } else { rows[row][col++] = null; } if (inserat.getT_erschienen() != null) { rows[row][col++] = Boolean.TRUE; } else { rows[row][col++] = Boolean.FALSE; } rows[row][col++] = inserat.getN_menge(); if (bDarfPreiseSehen) { rows[row][col++] = inserat.getN_nettoeinzelpreis_vk(); } else { rows[row][col++] = null; } rows[row][col++] = inserat.getStatus_c_nr(); rows[row][col++] = subStatusBezahlt; if (inseratrechnung != null && inseratrechnung.getFlrrechnungposition() != null) { rows[row][col++] = inseratrechnung.getFlrrechnungposition().getFlrrechnung().getC_nr(); } else { rows[row][col++] = null; } Set sEr = inserat.getErset(); if (sEr.size() > 0) { FLRInserater inserater = (FLRInserater) sEr.iterator().next(); rows[row][col++] = inserater.getFlreingangsrechnung().getC_nr(); } else { rows[row][col++] = null; } String tooltip = ""; if (inserat.getC_rubrik() != null) { tooltip += inserat.getC_rubrik() + " "; } if (inserat.getC_bez() != null) { if (inserat.getC_rubrik() != null) { tooltip += " | "; } tooltip += inserat.getC_bez() + " "; } if (inserat.getX_anhang() != null) { String text = "<b>" + tooltip + ":</b>\n" + inserat.getX_anhang(); text = text.replaceAll("\n", "<br>"); text = "<html>" + text + "</html>"; tooltip = text; } else { String text = "<b>" + tooltip + "</b>\n"; text = "<html>" + text + "</html>"; tooltip = text; } tooltipData[row] = tooltip; row++; col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0, tooltipData); } 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.inserat.fastlanereader.InseratrechnungHandler.java
License:Open Source License
/** * gets the data page for the specified row using the current query. The row * at rowIndex will be located in the middle of the page. * //from w w w . ja v a 2 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 = 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()) { FLRInseratrechnung inserat = (FLRInseratrechnung) resultListIterator.next(); rows[row][col++] = inserat.getI_id(); rows[row][col++] = inserat.getFlrkunde().getFlrpartner().getC_name1nachnamefirmazeile1(); rows[row][col++] = Helper.short2Boolean(inserat.getFlrkunde().getB_monatsrechnung()); if (inserat.getFlrrechnungposition() != null) { rows[row][col++] = inserat.getFlrrechnungposition().getFlrrechnung().getC_nr(); rows[row][col++] = inserat.getFlrrechnungposition().getFlrrechnung().getD_belegdatum(); rows[row][col++] = inserat.getFlrrechnungposition().getFlrrechnung().getStatus_c_nr(); } else { rows[row][col++] = null; rows[row][col++] = null; rows[row][col++] = null; } 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.instandhaltung.fastlanereader.AnlageHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* w ww.j a va 2s . c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = 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()) { FLRAnlage anlage = (FLRAnlage) resultListIterator.next(); rows[row][col++] = anlage.getI_id(); rows[row][col++] = anlage.getC_bez(); rows[row++][col++] = anlage.getFlrhalle().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.instandhaltung.fastlanereader.GeraetehistorieHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* ww w . jav a 2 s .co m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = 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()) { FLRGeraetehistorie historie = (FLRGeraetehistorie) resultListIterator.next(); rows[row][col++] = historie.getI_id(); rows[row][col++] = historie.getT_wartung(); String nameTechniker = historie.getFlrpersonal_techniker().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (historie.getFlrpersonal_techniker().getFlrpartner().getC_name2vornamefirmazeile2() != null) { nameTechniker = historie.getFlrpersonal_techniker().getFlrpartner() .getC_name2vornamefirmazeile2() + " " + nameTechniker; } rows[row][col++] = nameTechniker; rows[row][col++] = Helper.short2Boolean(historie.getB_nichtmoeglich()); rows[row][col++] = historie.getT_aendern(); String nameErfasser = historie.getFlrpersonal_aendern().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (historie.getFlrpersonal_aendern().getFlrpartner().getC_name2vornamefirmazeile2() != null) { nameErfasser = historie.getFlrpersonal_aendern().getFlrpartner().getC_name2vornamefirmazeile2() + " " + nameErfasser; } rows[row][col++] = nameErfasser; row++; 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; }