List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.artikel.fastlanereader.InventurprotokollHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// ww w .j a v a2 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; Locale locui = theClientDto.getLocUi(); while (resultListIterator.hasNext()) { FLRInventurprotokoll inventurprotokoll = (FLRInventurprotokoll) resultListIterator.next(); rows[row][col++] = inventurprotokoll.getI_id(); rows[row][col++] = inventurprotokoll.getFlrinventurliste().getFlrartikel().getC_nr(); ArtikelDto artikelDto = getArtikelFac().artikelFindByPrimaryKeySmall( inventurprotokoll.getFlrinventurliste().getFlrartikel().getI_id(), theClientDto); rows[row][col++] = artikelDto.formatBezeichnung(); rows[row][col++] = inventurprotokoll.getFlrinventurliste().getFlrlager().getC_nr(); rows[row][col++] = new java.sql.Timestamp(inventurprotokoll.getT_zeitpunkt().getTime()); rows[row][col++] = inventurprotokoll.getFlrinventurliste().getC_seriennrchargennr(); rows[row++][col++] = inventurprotokoll.getN_korrekturmenge(); 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.InventurstandHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w . ja v a2 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; Integer lastArtikelId = new Integer(-1); ArtikelDto artikelDto = null; while (resultListIterator.hasNext()) { FLRInventurstand inventurliste = (FLRInventurstand) resultListIterator.next(); rows[row][col++] = inventurliste.getI_id(); if (!lastArtikelId.equals(inventurliste.getFlrartikel().getI_id())) { artikelDto = getArtikelFac() .artikelFindByPrimaryKeySmall(inventurliste.getFlrartikel().getI_id(), theClientDto); } rows[row][col++] = artikelDto.getCNr(); rows[row][col++] = artikelDto.formatBezeichnung(); rows[row][col++] = inventurliste.getFlrlager().getC_nr(); rows[row][col++] = inventurliste.getN_inventurmenge(); rows[row++][col++] = inventurliste.getN_inventurpreis(); col = 0; lastArtikelId = inventurliste.getFlrartikel().getI_id(); } 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.KatalogHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w. ja 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()) { FLRKatalog katalog = (FLRKatalog) resultListIterator.next(); rows[row][col++] = katalog.getI_id(); rows[row][col++] = katalog.getC_katalog(); rows[row++][col++] = katalog.getC_seite(); 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.KundenidentnummerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// ww w. j a va2 s . com SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; Iterator resultListIterator = null; List resultList = null; Object[][] rows = 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(); session = setFilter(session); String queryString = getFromClause() + buildWhereClause() + buildOrderByClause(); Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); resultList = query.list(); resultListIterator = resultList.iterator(); rows = new Object[resultList.size()][colCount]; resultListIterator = resultList.iterator(); int row = 0; while (resultListIterator.hasNext()) { Object o[] = (Object[]) resultListIterator.next(); Object[] rowToAddCandidate = new Object[colCount]; rowToAddCandidate[0] = o[0]; rowToAddCandidate[1] = o[1]; rowToAddCandidate[2] = o[2]; rowToAddCandidate[3] = o[3]; rowToAddCandidate[4] = o[4]; rowToAddCandidate[5] = o[5]; rowToAddCandidate[6] = o[6]; rows[row] = rowToAddCandidate; row++; } result = new QueryResult(rows, 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.LagercockpitArtikelHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w ww .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(); 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(); FLRArtikellager artikellager = (FLRArtikellager) o[0]; FLRArtikellistespr artikellistespr = (FLRArtikellistespr) o[1]; rows[row][col++] = artikellager.getFlrartikel().getI_id(); rows[row][col++] = artikellager.getFlrartikel().getC_nr(); if (artikellistespr != null) { rows[row][col++] = artikellistespr.getC_bez(); } else { rows[row][col++] = null; } rows[row++][col++] = artikellager.getN_lagerstand(); 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.LagercockpitFehlmengeHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from www .j a v a2 s . c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = 9999999; 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(); // Lagerstand BigDecimal lagerstand = null; HashMap<String, BigDecimal> hmLagerstaende = getLagerFac() .getLagerstaendeAllerLagerartenOhneKeinLager(artikelIId, theClientDto); lagerstand = hmLagerstaende.get(LagerFac.LAGERART_WARENEINGANG); if (lagerstand == null) { lagerstand = new BigDecimal(0); } Query query = session.createQuery(queryString); query.setFirstResult(startIndex); query.setMaxResults(pageSize); List<?> resultList = query.list(); Iterator<?> resultListIterator = resultList.iterator(); ArrayList alZeilen = new ArrayList(); int row = 0; int col = 0; while (resultListIterator.hasNext()) { Object[] o = (Object[]) resultListIterator.next(); FLRFehlmenge fm = (FLRFehlmenge) o[0]; Object[] zeile = new Object[colCount]; zeile[0] = fm.getI_id(); zeile[1] = fm.getFlrartikel().getC_nr(); zeile[2] = getArtikelFac().artikelFindByPrimaryKeySmall(fm.getFlrartikel().getI_id(), theClientDto) .formatBezeichnung(); zeile[3] = fm.getN_menge(); lagerstand = lagerstand.subtract(fm.getN_menge()); String losnummerProjekt = fm.getFlrlossollmaterial().getFlrlos().getC_nr(); if (fm.getFlrlossollmaterial().getFlrlos().getC_projekt() != null) { losnummerProjekt += " " + fm.getFlrlossollmaterial().getFlrlos().getC_projekt(); } zeile[4] = losnummerProjekt; Integer lagerIId = null; LagerDto lDto = getLagerFac().getLagerDesErstenArtikellagerplatzes(fm.getFlrartikel().getI_id(), theClientDto); if (lDto != null) { lagerIId = lDto.getIId(); } String sLagerplaetze = getLagerFac().getLagerplaezteEinesArtikels(fm.getFlrartikel().getI_id(), null); boolean bMehrerLagerplaetze = false; if (sLagerplaetze != null && sLagerplaetze.split(",").length > 2) { bMehrerLagerplaetze = true; } if (bMehrerLagerplaetze == true && lagerIId != null) { zeile[5] = getLagerFac().getLagerplaezteEinesArtikels(fm.getFlrartikel().getI_id(), lagerIId) + " ++"; } else { zeile[5] = getLagerFac().getLagerplaezteEinesArtikels(fm.getFlrartikel().getI_id(), lagerIId); } alZeilen.add(zeile); } if (lagerstand.doubleValue() > 0) { // Noch 2 Zeilen hinzufuegen Object[] zeile = new Object[colCount]; zeile[0] = -1; zeile[1] = "---------"; zeile[2] = "----------------------------------------------------------------------"; alZeilen.add(zeile); zeile = new Object[5]; ArtikelDto aDto = getArtikelFac().artikelFindByPrimaryKeySmall(artikelIId, theClientDto); zeile[0] = -1; zeile[1] = aDto.getCNr(); zeile[2] = "Verbleibende Menge:"; zeile[3] = lagerstand; alZeilen.add(zeile); } Object[][] rows = new Object[alZeilen.size()][colCount]; rows = (Object[][]) alZeilen.toArray(rows); 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.LagercockpitLossollmaterialHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;//from w w w.java 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 = "SELECT umbuchung FROM FLRLagercockpitumbuchung umbuchung LEFT OUTER JOIN umbuchung.flrlager_lagerplatz as flrlager_lagerplatz " + 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()) { FLRLagercockpitumbuchung losmat = (FLRLagercockpitumbuchung) resultListIterator.next(); rows[row][col++] = losmat.getI_id(); rows[row][col++] = losmat.getFlrartikel().getC_nr(); rows[row][col++] = getArtikelFac() .artikelFindByPrimaryKeySmall(losmat.getFlrartikel().getI_id(), theClientDto) .formatBezeichnung(); BigDecimal bdmenge = losmat.getDiff(); // PJ18114 if (bdmenge.doubleValue() > 0 && losmat.getLagerstand().doubleValue() < bdmenge.doubleValue()) { bdmenge = losmat.getLagerstand(); } rows[row][col++] = bdmenge; String losnummerProjekt = losmat.getFlrlos().getC_nr(); if (losmat.getFlrlos().getC_projekt() != null) { losnummerProjekt += " " + losmat.getFlrlos().getC_projekt(); } rows[row][col++] = losnummerProjekt; Integer lagerIId = null; if (losmat.getLager_i_id_lagerplatz() != null) { rows[row][col++] = losmat.getFlrlager_lagerplatz().getC_nr(); lagerIId = losmat.getFlrlager_lagerplatz().getI_id(); } else { rows[row][col++] = null; } String sLagerplaetze = getLagerFac().getLagerplaezteEinesArtikels(losmat.getFlrartikel().getI_id(), null); boolean bMehrerLagerplaetze = false; if (sLagerplaetze != null && sLagerplaetze.split(",").length > 2) { bMehrerLagerplaetze = true; } if (bMehrerLagerplaetze == true && lagerIId != null) { rows[row][col++] = getLagerFac().getLagerplaezteEinesArtikels(losmat.getFlrartikel().getI_id(), lagerIId) + " ++"; } else { rows[row][col++] = getLagerFac().getLagerplaezteEinesArtikels(losmat.getFlrartikel().getI_id(), lagerIId); } if (losmat.getDiff().doubleValue() < 0) { rows[row][col++] = new Color(89, 188, 41); } 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.LagercockpitNichtLagerbewirtschafteteArtikelHandler.java
License:Open Source License
/** * The information needed for the kundes table. *//*from ww w . j a v a 2 s . co m*/ 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(); session = setFilter(session); String queryString = "SELECT wep from FLRWareneingangspositionen wep" + 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()) { FLRWareneingangspositionen wep = (FLRWareneingangspositionen) resultListIterator.next(); rows[row][col++] = wep.getI_id(); rows[row][col++] = wep.getFlrbestellposition().getFlrartikel().getC_nr(); String bez = null; ArtikelDto aDto = getArtikelFac().artikelFindByPrimaryKeySmall( wep.getFlrbestellposition().getFlrartikel().getI_id(), theClientDto); if (aDto.getArtikelsprDto() != null) { bez = aDto.getArtikelsprDto().getCBez(); } rows[row][col++] = bez; rows[row][col++] = wep.getFlrbestellposition().getFlrbestellung().getC_nr(); rows[row][col++] = wep.getFlrwareneingang().getC_lieferscheinnr(); rows[row++][col++] = wep.getN_geliefertemenge(); 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.LagerGrunddatenHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/* ww w . j ava 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()) { FLRLager lager = (FLRLager) resultListIterator.next(); rows[row][col++] = lager.getI_id(); rows[row][col++] = lager.getC_nr(); rows[row][col++] = lager.getLagerart_c_nr(); rows[row++][col++] = lager.getMandant_c_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.artikel.fastlanereader.LagerHandler.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 = 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()) { FLRLagerrolle lager = (FLRLagerrolle) resultListIterator.next(); rows[row][col++] = lager.getFlrlager().getI_id(); rows[row][col++] = lager.getFlrlager().getC_nr(); rows[row++][col++] = lager.getFlrlager().getLagerart_c_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; }