List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.fertigung.fastlanereader.LosstatusHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*w w w .j a v a 2s . c om*/ 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; HashMap<?, ?> hmStatus = getSystemMultilanguageFac().getAllStatiMitUebersetzung(theClientDto.getLocUi(), theClientDto); while (resultListIterator.hasNext()) { FLRLosstatus losstatus = (FLRLosstatus) resultListIterator.next(); rows[row][col++] = losstatus.getStatus_c_nr(); rows[row][col++] = ((String) hmStatus.get(losstatus.getStatus_c_nr())).trim(); ; 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.fertigung.fastlanereader.LostechnikerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w . j av a2s. 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; Locale locUI = theClientDto.getLocUi(); while (resultListIterator.hasNext()) { FLRLostechniker losab = (FLRLostechniker) resultListIterator.next(); rows[row][col++] = losab.getI_id(); rows[row][col++] = losab.getFlrpersonal().getC_personalnummer(); rows[row][col++] = losab.getFlrpersonal().getC_ausweis(); rows[row][col++] = losab.getFlrpersonal().getFlrpartner().getC_name1nachnamefirmazeile1(); rows[row][col++] = losab.getFlrpersonal().getFlrpartner().getC_name2vornamefirmazeile2(); rows[row][col++] = losab.getFlrpersonal().getC_kurzzeichen(); 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.fertigung.fastlanereader.LoszusatzstatusHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//ww w .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()) { FLRLoszusatzstatus zusatzstatus = (FLRLoszusatzstatus) resultListIterator.next(); rows[row][col++] = zusatzstatus.getI_id(); rows[row++][col++] = zusatzstatus.getFlrzusatzstatus().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.fertigung.fastlanereader.WiederholendeloseHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* w w w . j ava 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; int col = 0; while (resultListIterator.hasNext()) { FLRWiederholendelose funktion = (FLRWiederholendelose) resultListIterator.next(); rows[row][col++] = funktion.getI_id(); rows[row][col++] = funktion.getC_projekt(); rows[row][col++] = funktion.getAuftragwiederholungsintervall_c_nr(); rows[row][col++] = funktion.getT_termin(); rows[row][col++] = funktion.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 { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he); } } return result; }
From source file:com.lp.server.fertigung.fastlanereader.ZusatzstatusHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// w ww . j a v a2 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; int col = 0; while (resultListIterator.hasNext()) { FLRZusatzstatus zusatzstatus = (FLRZusatzstatus) resultListIterator.next(); rows[row][col++] = zusatzstatus.getI_id(); rows[row][col++] = zusatzstatus.getC_bez(); rows[row++][col++] = zusatzstatus.getI_sort(); 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.finanz.fastlanereader.BankkontoHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w ww.j av 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()) { FLRFinanzBankkonto bankkonto = (FLRFinanzBankkonto) resultListIterator.next(); rows[row][col++] = bankkonto.getI_id(); rows[row][col++] = bankkonto.getFlrkonto().getC_nr(); rows[row][col++] = bankkonto.getFlrbank().getFlrpartner().getC_name1nachnamefirmazeile1(); rows[row][col++] = bankkonto.getC_bez(); rows[row][col++] = Helper.formatIBAN(bankkonto.getC_iban()); rows[row][col++] = bankkonto.getFlrbank().getC_bic(); 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_FLR, he); } } return result; }
From source file:com.lp.server.finanz.fastlanereader.BuchungDetailBuchungsjournalHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// www. j a va2 s . c o m SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; BuchungdetailText buchungdetailText = new BuchungdetailText(getBenutzerServicesFac(), theClientDto); 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()) { Object o[] = (Object[]) resultListIterator.next(); FLRFinanzBuchungDetail buchungDetail = (FLRFinanzBuchungDetail) o[0]; // FLRFinanzBuchungDetail buchungDetail = (FLRFinanzBuchungDetail) resultListIterator // .next(); rows[row][col++] = buchungDetail.getI_id(); rows[row][col++] = buchungDetail.getFlrbuchung().getD_buchungsdatum(); rows[row][col++] = buchungDetail.getFlrkonto().getC_nr() + ", " + buchungDetail.getFlrkonto().getC_bez(); // String art = buchungDetail.getFlrbuchung().getFlrbuchungsart() // .getC_kbez(); // if (art == null) // art = "__"; // String belegart = ""; // if (buchungDetail.getFlrbuchung().getFlrfbbelegart() != null) // belegart = buchungDetail.getFlrbuchung().getFlrfbbelegart() // .getC_kbez(); // rows[row][col++] = art + belegart; rows[row][col++] = buchungdetailText.getTextFuerBuchungsart(buchungDetail.getFlrbuchung()); rows[row][col++] = buchungDetail.getFlrbuchung().getC_text(); if (buchungDetail.getBuchungdetailart_c_nr().equals(BuchenFac.HabenBuchung)) { rows[row][col++] = null; rows[row][col++] = buchungDetail.getN_betrag(); } else { rows[row][col++] = buchungDetail.getN_betrag(); rows[row][col++] = null; } rows[row][col++] = buchungDetail.getN_ust(); FLRFinanzKonto gegenkonto = buchungDetail.getFlrgegenkonto(); if (gegenkonto != null) { rows[row][col++] = gegenkonto.getC_nr() + ", " + gegenkonto.getC_bez(); } else { rows[row][col++] = ""; } rows[row][col++] = buchungDetail.getI_auszug(); if (buchungDetail.getFlrbuchung().getT_storniert() != null) { rows[row][col++] = LocaleFac.STATUS_STORNIERT; } 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_FLR, he); } } return result; }
From source file:com.lp.server.finanz.fastlanereader.BuchungDetailHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*w w w. j a v a2 s . c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; BuchungdetailText buchungdetailText = new BuchungdetailText(getBenutzerServicesFac(), theClientDto); 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]; String[] tooltipData = new String[resultList.size()]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { Object o[] = (Object[]) resultListIterator.next(); FLRFinanzBuchungDetail buchungDetail = (FLRFinanzBuchungDetail) o[0]; FLRFinanzBuchung buchung = buchungDetail.getFlrbuchung(); rows[row][col++] = buchungDetail.getI_id(); rows[row][col++] = buchung.getD_buchungsdatum(); rows[row][col++] = buchung.getC_belegnummer(); rows[row][col++] = buchungdetailText.getTextFuerAutomatischeEBBuchung(buchung); rows[row][col++] = buchungdetailText.getTextFuerBuchungsart(buchung); rows[row][col++] = buchung.getC_text(); if (buchungDetail.getBuchungdetailart_c_nr().equals(BuchenFac.HabenBuchung)) { rows[row][col++] = null; rows[row][col++] = buchungDetail.getN_betrag(); } else { rows[row][col++] = buchungDetail.getN_betrag(); rows[row][col++] = null; } rows[row][col++] = buchungDetail.getN_ust(); FLRFinanzKonto gegenkonto = buchungDetail.getFlrgegenkonto(); if (gegenkonto != null) { rows[row][col++] = gegenkonto.getC_nr() + ", " + gegenkonto.getC_bez(); } else { rows[row][col++] = ""; } rows[row][col++] = buchungDetail.getI_auszug(); rows[row][col++] = buchungDetail.getI_ausziffern(); if (buchungDetail.getFlrbuchung().getT_storniert() != null) { rows[row][col++] = LocaleFac.STATUS_STORNIERT; } else { rows[row][col++] = null; } if (buchungDetail.getKommentar() != null) { rows[row][col++] = !buchungDetail.getKommentar().isEmpty(); tooltipData[row] = buchungDetail.getKommentar().isEmpty() ? null : Helper.removeStyles(buchungDetail.getKommentar()); } else { rows[row][col++] = false; } if (Helper.short2boolean(buchung.getB_autombuchung())) { rows[row][col++] = Color.CYAN.darker(); } else { rows[row][col++] = null; } 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_FLR, he); } } return result; }
From source file:com.lp.server.finanz.fastlanereader.BuchungDetailKassenbuchHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// ww w . j av 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()) { FLRFinanzBuchungDetail buchungDetail = (FLRFinanzBuchungDetail) resultListIterator.next(); rows[row][col++] = buchungDetail.getI_id(); rows[row][col++] = buchungDetail.getFlrbuchung().getD_buchungsdatum(); // if (buchungDetail.getBuchungdetailart_c_nr().equals(BuchenFac.SollBuchung)) { if (buchungDetail.getBuchungdetailart_c_nr().equals(BuchenFac.HabenBuchung)) { rows[row][col++] = null; rows[row][col++] = buchungDetail.getN_betrag(); } else { rows[row][col++] = buchungDetail.getN_betrag(); rows[row][col++] = null; } /* BigDecimal prozent = null; prozent = Helper.getProzentsatzBD( buchungDetail.getN_betrag().subtract(buchungDetail.getN_ust()), buchungDetail.getN_ust(), FinanzFac.NACHKOMMASTELLEN); rows[row][col++] = prozent; */ rows[row][col++] = buchungDetail.getN_ust(); rows[row][col++] = buchungDetail.getFlrbuchung().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_FLR, he); } } return result; }
From source file:com.lp.server.finanz.fastlanereader.BuchungHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w . j a 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; int col = 0; while (resultListIterator.hasNext()) { FLRFinanzBuchung buchung = (FLRFinanzBuchung) resultListIterator.next(); rows[row][col++] = buchung.getI_id(); rows[row][col++] = Helper.extractDate(buchung.getT_anlegen()); rows[row][col++] = buchung.getD_buchungsdatum(); rows[row][col++] = Helper.short2boolean(buchung.getB_autombuchungeb()) ? "E" : ""; rows[row][col++] = buchung.getBuchungsart_c_nr(); rows[row][col++] = buchung.getC_belegnummer(); rows[row][col++] = buchung.getC_text(); if (buchung.getT_storniert() != null) { rows[row][col++] = LocaleFac.STATUS_GESPERRT; } 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_FLR, he); } } return result; }