List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.artikel.fastlanereader.LagerplatzHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w . java 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()) { FLRLagerplatz lagerplatz = (FLRLagerplatz) resultListIterator.next(); rows[row][col++] = lagerplatz.getI_id(); rows[row][col++] = lagerplatz.getC_lagerplatz(); rows[row++][col++] = lagerplatz.getFlrlager().getC_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.MaterialHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w .ja v a 2s. c o m SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = this.getTableInfo().getColumnClasses().length; int pageSize = MaterialHandler.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(); FLRMaterial material = (FLRMaterial) o[0]; Iterator<?> sprsetIterator = material.getMaterialsprset().iterator(); rows[row][col++] = material.getI_id(); rows[row][col++] = material.getC_nr(); rows[row][col++] = findSpr(sLocUI, sprsetIterator); 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.MaterialzuschlagHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//ww w . 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()) { FLRMaterialzuschlag materialzuschlag = (FLRMaterialzuschlag) resultListIterator.next(); rows[row][col++] = materialzuschlag.getI_id(); rows[row][col++] = materialzuschlag.getT_gueltigab(); rows[row++][col++] = materialzuschlag.getN_zuschlag(); 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.PaternosterHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// w w w.ja v a 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(); 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()) { FLRPaternoster paternoster = (FLRPaternoster) resultListIterator.next(); rows[row][col++] = paternoster.getI_id(); rows[row][col++] = paternoster.getC_nr(); rows[row][col++] = paternoster.getC_bez(); rows[row][col++] = paternoster.getC_paternostertyp(); rows[row++][col++] = paternoster.getFlrlager().getC_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.PreislistennameHandler.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; while (resultListIterator.hasNext()) { int col = 0; FLRVkpfartikelpreisliste oPreisliste = (FLRVkpfartikelpreisliste) resultListIterator.next(); rows[row][col++] = oPreisliste.getI_id(); rows[row][col++] = oPreisliste.getC_nr(); rows[row][col++] = oPreisliste.getWaehrung_c_nr(); rows[row][col++] = oPreisliste.getN_standardrabattsatz(); rows[row][col++] = oPreisliste.getB_preislisteaktiv(); rows[row][col++] = oPreisliste.getI_sort(); row++; } 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.SeriennummernchargennummernAufLagerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w . j a v a2 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(); 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()) { FLRLagerbewegung lagerbewegung = (FLRLagerbewegung) resultListIterator.next(); rows[row][col++] = lagerbewegung.getC_seriennrchargennr(); rows[row][col++] = lagerbewegung.getC_seriennrchargennr(); rows[row++][col++] = new java.sql.Date(lagerbewegung.getT_buchungszeit().getTime()) + " - " + new java.sql.Time(lagerbewegung.getT_buchungszeit().getTime()).toString(); 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.ShopgruppeHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from www . j ava 2 s . co m*/ 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(); FLRShopgruppe artikelklasse = (FLRShopgruppe) o[0]; Iterator<?> sprsetIterator = artikelklasse.getShopgruppesprset().iterator(); rows[row][col++] = artikelklasse.getI_id(); rows[row][col++] = artikelklasse.getC_nr(); rows[row][col++] = findSpr(sLocUI, sprsetIterator); rows[row][col++] = artikelklasse.getFlrshopgruppe() == null ? null : artikelklasse.getFlrshopgruppe().getC_nr(); if (artikelklasse.getFlrshopgruppe() != null) { Iterator<?> sprsetIteratorV = artikelklasse.getFlrshopgruppe().getShopgruppesprset().iterator(); rows[row][col++] = findSpr(sLocUI, sprsetIteratorV); } else { rows[row][col++] = null; } 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.ShopgruppewebshopHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from www . j ava2s . 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 = 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()) { FLRShopgruppewebshop flrArtikelsperren = (FLRShopgruppewebshop) resultListIterator.next(); rows[row][col++] = flrArtikelsperren.getI_id(); rows[row++][col++] = flrArtikelsperren.getFlrwebshop().getC_bez(); 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.SnrChnrFuerReklamationHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w.jav a 2s . 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(); 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(); FLRLagerbewegung lagerbewegung = (FLRLagerbewegung) o[0]; rows[row][col++] = lagerbewegung.getI_id(); rows[row][col++] = lagerbewegung.getC_seriennrchargennr(); rows[row][col++] = lagerbewegung.getFlrartikel().getC_nr(); rows[row][col++] = o[1]; try { BelegInfos biDto = getLagerFac().getBelegInfos(lagerbewegung.getC_belegartnr(), lagerbewegung.getI_belegartid(), lagerbewegung.getI_belegartpositionid(), theClientDto); rows[row][col++] = lagerbewegung.getC_belegartnr(); rows[row][col++] = biDto.getBelegnummer(); rows[row][col++] = biDto.getKundeLieferant(); if (biDto.getBelegdatum() != null) { rows[row][col++] = new java.util.Date(biDto.getBelegdatum().getTime()); } } catch (RemoteException e) { throwEJBExceptionLPRespectOld(e); } 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.SperrenHandler.java
License:Open Source License
/** * The information needed for the kundes table. * /*ww w .j a va2s.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()) { FLRSperren artikelkommentar = (FLRSperren) resultListIterator.next(); rows[row][col++] = artikelkommentar.getI_id(); rows[row][col++] = artikelkommentar.getC_bez(); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_gesperrt())); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_gesperrteinkauf())); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_gesperrtverkauf())); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_gesperrtlos())); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_gesperrtstueckliste())); rows[row][col++] = new Boolean(Helper.short2boolean(artikelkommentar.getB_durchfertigung())); 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; }