List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.artikel.fastlanereader.ArtikelreservierungHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* w w w . ja v a 2 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; while (resultListIterator.hasNext()) { FLRArtikelreservierung auftragreservierung = (FLRArtikelreservierung) resultListIterator.next(); rows[row][col++] = auftragreservierung.getI_id(); String sBelegnummer = null; String sPartner = null; String sProjektbezeichnung = null; if (auftragreservierung.getC_belegartnr().equals(LocaleFac.BELEGART_AUFTRAG)) { AuftragpositionDto auftragpositionDto = getAuftragpositionFac() .auftragpositionFindByPrimaryKey(auftragreservierung.getI_belegartpositionid()); AuftragDto auftragDto = getAuftragFac() .auftragFindByPrimaryKey(auftragpositionDto.getBelegIId()); sBelegnummer = auftragDto.getCNr(); sPartner = getKundeFac() .kundeFindByPrimaryKey(auftragDto.getKundeIIdAuftragsadresse(), theClientDto) .getPartnerDto().formatTitelAnrede(); sProjektbezeichnung = auftragDto.getCBezProjektbezeichnung(); } rows[row][col++] = sBelegnummer; rows[row][col++] = sPartner; rows[row][col++] = sProjektbezeichnung; rows[row][col++] = auftragreservierung.getT_liefertermin(); rows[row++][col++] = auftragreservierung.getN_menge(); col = 0; } result = new QueryResult(rows, this.getRowCount(), startIndex, endIndex, 0); } catch (Exception e) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, e); } finally { try { session.close(); } catch (HibernateException he) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER, he); } } return result; }
From source file:com.lp.server.artikel.fastlanereader.ArtikelshopgruppeHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w.j a va2 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 = ArtikelshopgruppeHandler.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()) { FLRArtikelshopgruppe flrArtikelshopgruppe = (FLRArtikelshopgruppe) resultListIterator.next(); rows[row][col++] = flrArtikelshopgruppe.getI_id(); rows[row][col++] = flrArtikelshopgruppe.getFlrshopgruppe().getC_nr(); rows[row++][col++] = getArtikelFac() .shopgruppeFindByPrimaryKey(flrArtikelshopgruppe.getShopgruppe_i_id(), theClientDto) .getBezeichnung(); 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.artikel.fastlanereader.ArtikelsperrenHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*w ww . j av a2 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()) { FLRArtikelsperren flrArtikelsperren = (FLRArtikelsperren) resultListIterator.next(); rows[row][col++] = flrArtikelsperren.getI_id(); rows[row][col++] = flrArtikelsperren.getFlrsperren().getC_bez(); rows[row++][col++] = flrArtikelsperren.getC_grund(); 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.artikel.fastlanereader.EinkaufseanHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w .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()) { FLREinkaufsean einkaufsean = (FLREinkaufsean) resultListIterator.next(); rows[row][col++] = einkaufsean.getI_id(); rows[row][col++] = einkaufsean.getN_menge(); rows[row++][col++] = einkaufsean.getC_ean(); 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.artikel.fastlanereader.FarbcodeHandler.java
License:Open Source License
/** * The information needed for the kundes table. * // w w w . j a v a 2 s . 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; String sLocUI = Helper.locale2String(theClientDto.getLocUi()); while (resultListIterator.hasNext()) { FLRFarbcode artikelkommentarart = (FLRFarbcode) resultListIterator.next(); rows[row][col++] = artikelkommentarart.getI_id(); rows[row][col++] = artikelkommentarart.getC_nr(); rows[row][col++] = artikelkommentarart.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.artikel.fastlanereader.FehlmengeAufloesenHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from ww w.j a v a 2 s . 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; while (resultListIterator.hasNext()) { FLRFehlmenge fm = (FLRFehlmenge) resultListIterator.next(); rows[row][col++] = fm.getI_id(); rows[row][col++] = fm.getFlrlossollmaterial().getFlrlos().getC_nr(); rows[row][col++] = fm.getFlrartikel().getC_nr(); rows[row][col++] = getArtikelFac() .artikelFindByPrimaryKeySmall(fm.getFlrartikel().getI_id(), theClientDto) .formatBezeichnung(); rows[row][col++] = fm.getN_menge(); if (bEndeStattBeginnTermin) { rows[row][col++] = fm.getFlrlossollmaterial().getFlrlos().getT_produktionsende(); } else { rows[row][col++] = fm.getT_liefertermin(); } if (fm.getFlrlossollmaterial() != null && fm.getFlrlossollmaterial().getFlrlos().getFlrstueckliste() != null) { rows[row][col++] = Helper.short2Boolean(fm.getFlrlossollmaterial().getFlrlos() .getFlrstueckliste().getB_materialbuchungbeiablieferung()); } 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 { closeSession(session); } return result; }
From source file:com.lp.server.artikel.fastlanereader.FehlmengeHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w . ja va 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; BestellpositionDto bestellpositionDtos[] = null; 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(); FLRFehlmenge fm = (FLRFehlmenge) o[0]; rows[row][col++] = fm.getI_id(); rows[row][col++] = fm.getFlrlossollmaterial().getFlrlos().getC_nr(); rows[row][col++] = fm.getFlrartikel().getC_nr(); rows[row][col++] = getArtikelFac() .artikelFindByPrimaryKeySmall(fm.getFlrartikel().getI_id(), theClientDto) .formatBezeichnung(); rows[row][col++] = fm.getN_menge(); rows[row][col++] = fm.getT_liefertermin(); java.sql.Date dFruehesterEintreffTermin = null; bestellpositionDtos = getBestellpositionFac() .bestellpositionfindByArtikelOrderByTAuftragsbestaetigungstermin( fm.getFlrartikel().getI_id(), theClientDto); if (bestellpositionDtos != null) { for (int i = 0; i < bestellpositionDtos.length; i++) { if (!bestellpositionDtos[i].getBestellpositionstatusCNr() .equals(BestellpositionFac.BESTELLPOSITIONSTATUS_ERLEDIGT)) { if (bestellpositionDtos[i].getNOffeneMenge() == null || bestellpositionDtos[i].getNOffeneMenge().doubleValue() > 0) { dFruehesterEintreffTermin = bestellpositionDtos[i] .getTAuftragsbestaetigungstermin(); break; } } } } rows[row][col++] = dFruehesterEintreffTermin; if (fm.getFlrlossollmaterial() != null && fm.getFlrlossollmaterial().getFlrlos().getFlrstueckliste() != null) { rows[row][col++] = Helper.short2Boolean(fm.getFlrlossollmaterial().getFlrlos() .getFlrstueckliste().getB_materialbuchungbeiablieferung()); } else { rows[row][col++] = null; } // Lagerstand BigDecimal lagerstand = new BigDecimal(0); LoslagerentnahmeDto[] lolaeDtos = getFertigungFac() .loslagerentnahmeFindByLosIId(fm.getFlrlossollmaterial().getFlrlos().getI_id()); for (int i = 0; i < lolaeDtos.length; i++) { if (Helper.short2boolean(fm.getFlrartikel().getB_lagerbewirtschaftet())) { BigDecimal lagerstandEisneLagers = getLagerFac().getLagerstand(fm.getFlrartikel().getI_id(), lolaeDtos[i].getLagerIId(), theClientDto); if (lagerstandEisneLagers != null) { lagerstand = lagerstand.add(lagerstandEisneLagers); } } } rows[row][col++] = lagerstand; if (o[1] != null) { rows[row][col++] = LocaleFac.STATUS_GESPERRT; } else { rows[row][col++] = null; } if (fm.getN_menge().doubleValue() > lagerstand.doubleValue()) { rows[row][col++] = Color.RED; } 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 { closeSession(session); } return result; }
From source file:com.lp.server.artikel.fastlanereader.HandlagerbewegungHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from ww w. j a va 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(); session = setFilter(session); 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(); FLRHandlagerbewegung handlagerbewegung = (FLRHandlagerbewegung) o[0]; rows[row][col++] = handlagerbewegung.getI_id(); rows[row][col++] = handlagerbewegung.getT_buchungszeit(); rows[row][col++] = handlagerbewegung.getFlrartikel().getC_nr(); rows[row][col++] = o[1]; rows[row][col++] = handlagerbewegung.getFlrlager().getC_nr(); // Wenn Lagerabgang, dann negative Menge if (Helper.short2boolean(handlagerbewegung.getB_abgang())) { rows[row][col++] = handlagerbewegung.getN_menge().negate(); } else { rows[row][col++] = handlagerbewegung.getN_menge(); } rows[row++][col++] = handlagerbewegung.getC_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.artikel.fastlanereader.InventurHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from ww w. j a v a 2 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; while (resultListIterator.hasNext()) { FLRInventur inventur = (FLRInventur) resultListIterator.next(); rows[row][col++] = inventur.getI_id(); rows[row][col++] = inventur.getT_inventurdatum(); rows[row][col++] = inventur.getC_bez(); if (inventur.getFlrlager() != null) { rows[row][col++] = inventur.getFlrlager().getC_nr(); } else { rows[row][col++] = null; } rows[row][col++] = Helper.short2Boolean(inventur.getB_inventurdurchgefuehrt()); String person = ""; if (inventur.getFlrpersonalinventurdurchgefuehrt() != null) { person = inventur.getFlrpersonalinventurdurchgefuehrt().getFlrpartner() .getC_name1nachnamefirmazeile1(); if (inventur.getFlrpersonalinventurdurchgefuehrt().getFlrpartner() .getC_name2vornamefirmazeile2() != null) { person += " " + inventur.getFlrpersonalinventurdurchgefuehrt().getFlrpartner() .getC_name2vornamefirmazeile2(); } } rows[row++][col++] = person; 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.artikel.fastlanereader.InventurlisteHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w .ja v 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(); session = setFilter(session); 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(); rows[row][col++] = o[0]; String artikel = (String) o[1]; if (o[2] != null) { artikel += " " + (String) o[2]; } rows[row][col++] = artikel; rows[row][col++] = o[3]; rows[row][col++] = o[4]; rows[row++][col++] = o[5]; 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; }