List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.instandhaltung.fastlanereader.WartungslisteHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w ww . 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 = "SELECT wartungsliste FROM FLRWartungsliste wartungsliste" + 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()) { FLRWartungsliste wartungsliste = (FLRWartungsliste) resultListIterator.next(); rows[row][col++] = wartungsliste.getI_id(); if (wartungsliste.getFlrartikel() != null) { ArtikelDto dto = getArtikelFac() .artikelFindByPrimaryKeySmall(wartungsliste.getFlrartikel().getI_id(), theClientDto); rows[row][col++] = dto.getCNr(); rows[row][col++] = dto.formatBezeichnung(); } else { rows[row][col++] = ""; rows[row][col++] = wartungsliste.getC_bez(); } rows[row][col++] = wartungsliste.getN_menge(); // Text if (wartungsliste.getX_bemerkung() != null && !wartungsliste.getX_bemerkung().equals("")) { rows[row][col++] = new Boolean(true); String text = wartungsliste.getX_bemerkung(); text = text.replaceAll("\n", "<br>"); text = "<html>" + text + "</html>"; tooltipData[row] = text; } else { rows[row][col++] = new Boolean(false); } row++; 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.instandhaltung.fastlanereader.WartungsschritteHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from 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 = "SELECT wartungsschritte FROM FLRWartungsschritte wartungsschritte" + 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]; ParametermandantDto parameter = null; try { parameter = (ParametermandantDto) getParameterFac().getMandantparameter(theClientDto.getMandant(), ParameterFac.KATEGORIE_STUECKLISTE, ParameterFac.PARAMETER_STUECKLISTE_ARBEITSPLAN_ZEITEINHEIT); } catch (RemoteException ex) { throwEJBExceptionLPRespectOld(ex); } String sEinheit = parameter.getCWert().trim(); String[] tooltipData = new String[resultList.size()]; int row = 0; int col = 0; while (resultListIterator.hasNext()) { FLRWartungsschritte wartungsliste = (FLRWartungsschritte) resultListIterator.next(); rows[row][col++] = wartungsliste.getI_id(); ArtikelDto dto = getArtikelFac() .artikelFindByPrimaryKeySmall(wartungsliste.getFlrartikel().getI_id(), theClientDto); rows[row][col++] = dto.getCNr(); rows[row][col++] = dto.formatBezeichnung(); rows[row][col++] = wartungsliste.getAuftragwiederholungsintervall_c_nr(); double lDauer = wartungsliste.getL_dauer().longValue(); double dDauer = 0; if (sEinheit.equals(SystemFac.EINHEIT_STUNDE.trim())) { dDauer = lDauer / 3600000; } else if (sEinheit.equals(SystemFac.EINHEIT_MINUTE.trim())) { dDauer = lDauer / 60000; } else if (sEinheit.equals(SystemFac.EINHEIT_SEKUNDE.trim())) { dDauer = lDauer / 100; } rows[row][col++] = new BigDecimal(dDauer); row++; 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.kueche.fastlanereader.BedienerlagerHandler.java
License:Open Source License
/** * The information needed for the kundes table. * /*from w ww.j a va2 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()) { FLRBedienerlager speisekassa = (FLRBedienerlager) resultListIterator.next(); rows[row][col++] = speisekassa.getI_id(); rows[row][col++] = speisekassa.getC_bedienernummer(); rows[row][col++] = speisekassa.getFlrlager().getC_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.kueche.fastlanereader.KassaartikelHandler.java
License:Open Source License
/** * The information needed for the kundes table. * /*from www.j a va2s.c om*/ * @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()) { FLRKassaartikel speisekassa = (FLRKassaartikel) resultListIterator.next(); rows[row][col++] = speisekassa.getI_id(); rows[row][col++] = speisekassa.getC_artikelnummerkassa(); rows[row][col++] = speisekassa.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.kueche.fastlanereader.Kdc100logHandler.java
License:Open Source License
/** * the size of the data page returned in QueryResult. * //from w ww . j a v a 2s . 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 = Kdc100logHandler.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()) { FLRKdc100log flrKdc100log = (FLRKdc100log) resultListIterator.next(); rows[row][col++] = flrKdc100log.getI_id(); rows[row][col++] = flrKdc100log.getC_seriennummer(); rows[row][col++] = flrKdc100log.getC_art(); rows[row][col++] = flrKdc100log.getC_barcode(); rows[row][col++] = flrKdc100log.getC_kommentar(); rows[row][col++] = flrKdc100log.getT_buchungszeit(); rows[row][col++] = flrKdc100log.getT_stiftzeit(); 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; }
From source file:com.lp.server.kueche.fastlanereader.KuecheumrechnungHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* www . j av a 2 s . 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()) { FLRKuecheumrechnung kuecheumrechnung = (FLRKuecheumrechnung) resultListIterator.next(); rows[row][col++] = kuecheumrechnung.getI_id(); rows[row][col++] = kuecheumrechnung.getC_artikelnummerkassa(); rows[row++][col++] = kuecheumrechnung.getN_faktor(); 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.kueche.fastlanereader.SpeiseplanHandler.java
License:Open Source License
/** * The information needed for the kundes table. * //from w ww . 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 = "SELECT speiseplan, aspr.c_bez FROM FLRSpeiseplan AS speiseplan LEFT OUTER JOIN speiseplan.flrstueckliste.flrartikel.artikelsprset AS aspr " + this.buildWhereClause() + this.buildOrderByClause(); session = setFilter(session); 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(); FLRSpeiseplan artikelkommentarart = (FLRSpeiseplan) o[0]; rows[row][col++] = artikelkommentarart.getI_id(); rows[row][col++] = artikelkommentarart.getFlrfertigungsgruppe().getC_bez(); rows[row][col++] = artikelkommentarart.getFlrstueckliste().getFlrartikel().getC_nr(); rows[row][col++] = o[1]; rows[row][col++] = artikelkommentarart.getN_menge(); rows[row][col++] = artikelkommentarart.getFlrkassaartikel().getC_artikelnummerkassa(); rows[row][col++] = artikelkommentarart.getFlrkassaartikel().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.kueche.fastlanereader.TageslosHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w. j a v a 2s . 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; while (resultListIterator.hasNext()) { FLRTageslos tageslos = (FLRTageslos) resultListIterator.next(); rows[row][col++] = tageslos.getI_id(); rows[row][col++] = tageslos.getC_bez(); rows[row++][col++] = tageslos.getFlrkostenstelle().getC_nr(); 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.lieferschein.fastlanereader.AuftraegeEinesLieferscheinsHandler.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. * //www. j a va2s .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(); // myLogger.info("HQL: " + queryString); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); HashMap<?, ?> hmStatus = getSystemMultilanguageFac().getAllStatiMitUebersetzung(theClientDto.getLocUi(), theClientDto); // verdichten TreeMap<String, Integer> hm = new TreeMap<String, Integer>(); while (resultListIterator.hasNext()) { FLRLieferscheinposition pos = (FLRLieferscheinposition) resultListIterator.next(); if (pos.getFlrpositionensichtauftrag() != null) { hm.put(pos.getFlrpositionensichtauftrag().getFlrauftrag().getC_nr(), pos.getFlrpositionensichtauftrag().getAuftrag_i_id()); } } // jetzt noch den Kopfauftrag dazu suchen (der koennte evtl. eh // schon dabei sein) if (this.getQuery() != null && this.getQuery().getFilterBlock() != null && this.getQuery().getFilterBlock().filterKrit != null) { FilterBlock filterBlock = this.getQuery().getFilterBlock(); FilterKriterium[] filterKriterien = this.getQuery().getFilterBlock().filterKrit; for (int i = 0; i < filterKriterien.length; i++) { if (filterKriterien[i].isKrit) { if (filterKriterien[i].kritName .equals(LieferscheinpositionFac.FLR_LIEFERSCHEINPOSITION_FLRLIEFERSCHEIN + "." + LieferscheinFac.FLR_LIEFERSCHEIN_I_ID)) { Integer lieferscheinIId = new Integer(filterKriterien[i].value); LieferscheinDto lsDto = getLieferscheinFac() .lieferscheinFindByPrimaryKey(lieferscheinIId, theClientDto); if (lsDto.getAuftragIId() != null) { AuftragDto auftragDto = getAuftragFac() .auftragFindByPrimaryKey(lsDto.getAuftragIId()); hm.put(auftragDto.getCNr(), lsDto.getAuftragIId()); } } } } } int row = 0; int col = 0; Object[][] rows = new Object[hm.size()][colCount]; for (Iterator<String> iter = hm.keySet().iterator(); iter.hasNext();) { String item = (String) iter.next(); Integer auftragIId = hm.get(item); AuftragDto auftragDto = getAuftragFac().auftragFindByPrimaryKey(auftragIId); rows[row][col++] = auftragDto.getIId(); rows[row][col++] = auftragDto.getCNr(); rows[row][col++] = auftragDto.getCBezProjektbezeichnung(); rows[row][col++] = auftragDto.getCBestellnummer(); rows[row++][col++] = hmStatus.get(auftragDto.getAuftragstatusCNr()); 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.lieferschein.fastlanereader.AuftragpositionInLieferscheinHandler.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 ww . ja v a 2 s . co 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 = AuftragpositionInLieferscheinHandler.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(); // myLogger.info("HQL: " + queryString); 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()) { FLRLieferscheinposition pos = (FLRLieferscheinposition) resultListIterator.next(); rows[row][col++] = pos.getI_id(); String cBelegkuerzel = getLocaleFac().belegartFindByCNr(LocaleFac.BELEGART_LIEFERSCHEIN) .getCKurzbezeichnung(); rows[row][col++] = cBelegkuerzel; rows[row][col++] = pos.getFlrlieferschein().getC_nr(); rows[row][col++] = pos.getFlrartikel().getC_nr(); // die Bezeichnung im uebersteuert in jedem Fall String sBezeichnung = pos.getC_bez(); if (pos.getPositionsart_c_nr().equals(LocaleFac.POSITIONSART_IDENT) && (sBezeichnung == null || sBezeichnung.length() == 0)) { // die sprachabhaengig Artikelbezeichnung anzeigen sBezeichnung = getArtikelFac().formatArtikelbezeichnungEinzeiligOhneExc( pos.getFlrartikel().getI_id(), theClientDto.getLocUi()); } rows[row][col++] = sBezeichnung; rows[row][col++] = pos.getN_menge(); rows[row++][col++] = pos.getFlrlieferschein().getD_belegdatum(); 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; }