List of usage examples for org.hibernate Query setMaxResults
@Override
Query<R> setMaxResults(int maxResult);
From source file:com.lp.server.artikel.fastlanereader.AlleSnrChnrHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w. j a v a2s. c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = 999999999; 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(); ArrayList alDtos = new ArrayList(); while (resultListIterator.hasNext()) { String s = (String) resultListIterator.next(); SeriennrChargennrAufLagerDto dto = new SeriennrChargennrAufLagerDto(); dto.setCSeriennrChargennr(s); dto.setNMenge(BigDecimal.ONE); alDtos.add(dto); } Collections.sort(alDtos, new ComparatorSnrChnrNumerisch(true)); Object[][] rows = new Object[alDtos.size()][colCount]; int row = 0; int col = 0; for (int i = 0; i < alDtos.size(); i++) { SeriennrChargennrAufLagerDto dto = (SeriennrChargennrAufLagerDto) alDtos.get(i); rows[row][col++] = dto.getCSeriennrChargennr(); rows[row][col++] = dto.getCSeriennrChargennr(); 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.artikel.fastlanereader.ArtikelbestelltHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from www.j ava 2s. 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()) { FLRArtikelbestellt artikelbestellt = (FLRArtikelbestellt) resultListIterator.next(); rows[row][col++] = artikelbestellt.getI_id(); String sBelegnummer = null; String sPartner = null; String sProjektbezeichnung = null; if (artikelbestellt.getC_belegartnr().equals(LocaleFac.BELEGART_BESTELLUNG)) { BestellpositionDto bestellpositionDto = getBestellpositionFac() .bestellpositionFindByPrimaryKey(artikelbestellt.getI_belegartpositionid()); BestellungDto bestellungDto = getBestellungFac() .bestellungFindByPrimaryKey(bestellpositionDto.getBestellungIId()); sBelegnummer = bestellungDto.getCNr(); sPartner = getLieferantFac() .lieferantFindByPrimaryKey(bestellungDto.getLieferantIIdBestelladresse(), theClientDto) .getPartnerDto().formatTitelAnrede(); sProjektbezeichnung = bestellungDto.getCBez(); } rows[row][col++] = sBelegnummer; rows[row][col++] = sPartner; rows[row][col++] = sProjektbezeichnung; rows[row][col++] = artikelbestellt.getT_liefertermin(); rows[row++][col++] = artikelbestellt.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.ArtikelgruHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w.jav a 2 s.c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = ArtikelgruHandler.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()) { Object o[] = (Object[]) resultListIterator.next(); FLRArtikelgruppe artikelgruppe = (FLRArtikelgruppe) o[0]; Iterator<?> sprsetIterator = artikelgruppe.getArtikelgruppesprset().iterator(); rows[row][col++] = artikelgruppe.getI_id(); rows[row][col++] = artikelgruppe.getC_nr(); rows[row][col++] = findSpr(sLocUI, sprsetIterator); rows[row][col++] = artikelgruppe.getFlrartikelgruppe() == null ? null : artikelgruppe.getFlrartikelgruppe().getC_nr(); if (artikelgruppe.getFlrartikelgruppe() != null) { Iterator<?> sprsetIteratorV = artikelgruppe.getFlrartikelgruppe().getArtikelgruppesprset() .iterator(); rows[row][col++] = findSpr(sLocUI, sprsetIteratorV); } else { rows[row][col++] = null; } rows[row][col++] = artikelgruppe.getFlrkonto() == null ? null : artikelgruppe.getFlrkonto().getC_nr(); 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_HIBERNATE, he); } } return result; }
From source file:com.lp.server.artikel.fastlanereader.ArtikelHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from ww w . j a v 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()) { FLRArtikel artikel = (FLRArtikel) resultListIterator.next(); rows[row][col++] = artikel.getI_id(); rows[row][col++] = artikel.getC_nr(); rows[row++][col++] = artikel.getArtikelart_c_nr(); 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.ArtikelherstellerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// www .j a v a 2 s.c o m SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = this.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()) { FLRHersteller hersteller = (FLRHersteller) resultListIterator.next(); rows[row][col++] = hersteller.getI_id(); rows[row][col++] = hersteller.getC_nr(); rows[row++][col++] = hersteller.getFlrpartner() == null ? null : hersteller.getFlrpartner().getC_name1nachnamefirmazeile1(); 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.ArtikelklaHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w ww . j av a 2 s . com*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = ArtikelklaHandler.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()) { Object o[] = (Object[]) resultListIterator.next(); FLRArtikelklasse artikelklasse = (FLRArtikelklasse) o[0]; Iterator<?> sprsetIterator = artikelklasse.getArtikelklassesprset().iterator(); rows[row][col++] = artikelklasse.getI_id(); rows[row][col++] = artikelklasse.getC_nr(); rows[row][col++] = findSpr(sLocUI, sprsetIterator); rows[row][col++] = artikelklasse.getFlrartikelklasse() == null ? null : artikelklasse.getFlrartikelklasse().getC_nr(); if (artikelklasse.getFlrartikelklasse() != null) { Iterator<?> sprsetIteratorV = artikelklasse.getFlrartikelklasse().getArtikelklassesprset() .iterator(); rows[row][col++] = findSpr(sLocUI, sprsetIteratorV); } else { rows[row][col++] = null; } rows[row][col++] = Helper.short2Boolean(artikelklasse.getB_tops()); 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.artikel.fastlanereader.ArtikelkommentarartHandler.java
License:Open Source License
/** * The information needed for the kundes table. * //from ww w.j av 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 = ArtikelkommentarartHandler.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()) { Object o[] = (Object[]) resultListIterator.next(); FLRArtikelkommentarart artikelkommentarart = (FLRArtikelkommentarart) o[0]; Iterator<?> sprsetIterator = artikelkommentarart.getArtikelkommentarartsprset().iterator(); rows[row][col++] = artikelkommentarart.getI_id(); rows[row][col++] = artikelkommentarart.getC_nr(); rows[row][col++] = findSpr(sLocUI, sprsetIterator); 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.ArtikelkommentarHandler.java
License:Open Source License
/** * The information needed for the kundes table. * //ww 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); 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 locale = theClientDto.getLocUiAsString(); while (resultListIterator.hasNext()) { FLRArtikelkommentar artikelkommentar = (FLRArtikelkommentar) resultListIterator.next(); rows[row][col++] = artikelkommentar.getI_id(); rows[row][col++] = artikelkommentar.getFlrartikelkommentarart().getC_nr(); rows[row][col++] = artikelkommentar.getDatenformat_c_nr(); try { ArtikelkommentarsprDto dto = getArtikelkommentarFac() .artikelkommentarsprFindByPrimaryKey(artikelkommentar.getI_id(), locale); if (dto != null) { String sStrippedHTML = null; if (dto.getXKommentar() != null) { sStrippedHTML = Helper.strippHTML(dto.getXKommentar()); } rows[row][col++] = sStrippedHTML; } else { rows[row][col++] = null; } } catch (RemoteException ex) { rows[row][col++] = null; } rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_defaultbild())); 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.artikel.fastlanereader.ArtikellagerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*ww w. j a v a 2s. com*/ 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; // darf Preise sehen. final boolean bDarfPreiseSehen = getTheJudgeFac().hatRecht(RechteFac.RECHT_LP_DARF_PREISE_SEHEN_EINKAUF, theClientDto); while (resultListIterator.hasNext()) { FLRArtikellager artikellager = (FLRArtikellager) resultListIterator.next(); ArtikelDto artikleDto = getArtikelFac() .artikelFindByPrimaryKey(artikellager.getCompId().getArtikel_i_id(), theClientDto); LagerDto lagerDto = getLagerFac().lagerFindByPrimaryKey(artikellager.getCompId().getLager_i_id()); rows[row][col++] = artikellager.getCompId(); rows[row][col++] = lagerDto.getCNr(); rows[row][col++] = artikellager.getN_lagerstand(); if (bDarfPreiseSehen) { rows[row][col++] = Helper.rundeKaufmaennisch(artikellager.getN_gestehungspreis(), 4); } else { rows[row][col++] = new BigDecimal(0); } double lagerwert = 0; lagerwert = artikellager.getN_lagerstand().doubleValue() * artikellager.getN_gestehungspreis().doubleValue(); if (Helper.short2boolean(artikleDto.getBLagerbewertet()) == true && bDarfPreiseSehen) { rows[row++][col++] = Helper.rundeKaufmaennisch(new java.math.BigDecimal(lagerwert), 4); } else { rows[row++][col++] = Helper.rundeKaufmaennisch(new java.math.BigDecimal(0), 4); } 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.ArtikellagerplaetzeHandler.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 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()) { FLRArtikellagerplaetze lager = (FLRArtikellagerplaetze) resultListIterator.next(); rows[row][col++] = lager.getI_id(); rows[row][col++] = lager.getFlrlagerplatz().getC_lagerplatz(); rows[row++][col++] = lager.getFlrlagerplatz().getFlrlager().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; }