List of usage examples for org.hibernate Query setFirstResult
@Override
Query<R> setFirstResult(int startPosition);
From source file:com.lp.server.partner.fastlanereader.LFLiefergruppenOneLFHandler.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 = 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 = FLR_SELECT + getFromClause() + buildWhereClause() + 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[1]; rows[row][col++] = o[0]; LfliefergruppeDto liefergruppeDto = getLieferantServicesFac() .lfliefergruppeFindByPrimaryKey((Integer) o[1], theClientDto); if (liefergruppeDto.getLfliefergruppesprDto() != null) { rows[row][col++] = liefergruppeDto.getLfliefergruppesprDto().getCBez(); } row++; 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.partner.fastlanereader.LieferantbeurteilungHandler.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 = 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()) { FLRLieferantbeurteilung massnahme = (FLRLieferantbeurteilung) resultListIterator.next(); rows[row][col++] = massnahme.getI_id(); rows[row][col++] = massnahme.getT_datum(); rows[row][col++] = massnahme.getI_punkte(); rows[row++][col++] = Helper.short2Boolean(massnahme.getB_gesperrt()); 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.partner.fastlanereader.LieferantHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;// ww w . jav a 2 s . c o m SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = LieferantHandler.PAGE_SIZE; int startIndex = Math.max(rowIndex.intValue() - (pageSize / 2), 0); int endIndex = startIndex + pageSize - 1; session = factory.openSession(); String queryString = getFromClause() + buildWhereClause() + 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]; rows[row][col++] = o[1]; rows[row][col++] = o[2]; rows[row][col++] = o[3]; if (o[4] != null) { rows[row][col++] = LocaleFac.STATUS_GESPERRT; } else { rows[row][col++] = null; } rows[row][col++] = o[5]; rows[row][col++] = o[6]; rows[row][col++] = o[7]; rows[row][col++] = o[8]; row++; 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.partner.fastlanereader.LiefergruppenHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w . j ava 2 s . c o m*/ SessionFactory factory = FLRSessionFactory.getFactory(); Session session = null; try { int colCount = getTableInfo().getColumnClasses().length; int pageSize = LiefergruppenHandler.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(); FLRLiefergruppe liefergruppe = (FLRLiefergruppe) o[0]; Iterator<?> sprsetIterator = liefergruppe.getLiefergruppe_liefergruppespr_set().iterator(); rows[row][col++] = liefergruppe.getI_id(); rows[row][col++] = liefergruppe.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.partner.fastlanereader.PAKurzbriefHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w .j a v a 2 s. com*/ 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()) { // flrjoin: 1 FLRKurzbrief kurzbrief = (FLRKurzbrief) resultListIterator.next(); rows[row][col++] = kurzbrief.getI_id(); rows[row][col++] = kurzbrief.getC_betreff(); if (kurzbrief.getFlransprechpartner() != null) { rows[row][col++] = kurzbrief.getFlransprechpartner().getFlrpartneransprechpartner() .getC_name1nachnamefirmazeile1(); } else { rows[row][col++] = null; } rows[row][col++] = kurzbrief.getFlrpersonal().getFlrpartner().getC_name1nachnamefirmazeile1(); rows[row][col++] = kurzbrief.getT_aendern(); 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.partner.fastlanereader.PartnerartHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from www . j a v a2 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); 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(); FLRPartnerart partnerart = (FLRPartnerart) o[0]; Iterator<?> sprsetIterator = partnerart.getPartnerart_partnerartspr_set().iterator(); rows[row][col++] = partnerart.getC_nr(); rows[row][col++] = partnerart.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.partner.fastlanereader.PartnerBankHandler.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. * /* ww w. j av a2 s .c o m*/ * @see UseCaseHandler#getPageAt(java.lang.Integer) * @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 = 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()) { FLRPartnerbank partnerbank = (FLRPartnerbank) resultListIterator.next(); rows[row][col++] = partnerbank.getI_id(); rows[row][col++] = partnerbank.getFlrpartner().getC_name1nachnamefirmazeile1(); BankDto bankDto = getBankFac().bankFindByPrimaryKey(partnerbank.getFlrpartner().getI_id(), theClientDto); rows[row][col++] = bankDto.getCBlz(); rows[row][col++] = partnerbank.getC_ktonr(); rows[row][col++] = Helper.formatIBAN(partnerbank.getC_iban()); rows[row][col++] = bankDto.getCBic(); if (partnerbank.getFlrpartner().getFlrlandplzort() != null) { rows[row][col++] = partnerbank.getFlrpartner().getFlrlandplzort().getFlrland().getC_lkz(); rows[row][col++] = partnerbank.getFlrpartner().getFlrlandplzort().getC_plz(); } else { rows[row][col++] = null; rows[row][col++] = null; } rows[row][col++] = partnerbank.getI_sort(); 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_FLR, he); } } return result; }
From source file:com.lp.server.partner.fastlanereader.PartnerHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from w w w .ja va2 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 = getFromClause() + buildWhereClause() + 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()) { // flrjoin: 1 Object[] o = (Object[]) resultListIterator.next(); rows[row][col++] = o[0]; rows[row][col++] = o[1]; rows[row][col++] = o[2]; rows[row][col++] = o[3]; rows[row][col++] = o[4]; rows[row][col++] = o[5]; rows[row][col++] = o[6]; rows[row][col++] = o[7]; row++; col = 0; } result = new QueryResult(rows, 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.partner.fastlanereader.PartnerklasseHandler.java
License:Open Source License
public QueryResult getPageAt(Integer rowIndex) throws EJBExceptionLP { QueryResult result = null;/*from ww w . j av a 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 = 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(); FLRPartnerklasse partnerklasse = (FLRPartnerklasse) o[0]; Iterator<?> sprsetIterator = partnerklasse.getPartnerklasse_partnerklassespr_set().iterator(); rows[row][col++] = partnerklasse.getI_id(); rows[row][col++] = partnerklasse.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.partner.fastlanereader.PartnerkommunikationHandler.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; PartnerDto d = 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 = getFromClause() + buildWhereClause() + 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()) { FLRPartnerkommunikation partnerkommunikation = (FLRPartnerkommunikation) resultListIterator.next(); rows[row][col++] = partnerkommunikation.getI_id(); String cNrMandant = partnerkommunikation.getMandant_c_nr(); rows[row][col++] = cNrMandant == null ? getTextRespectUISpr("lp.privat", theClientDto.getMandant(), theClientDto.getLocUi()) : cNrMandant; rows[row][col++] = partnerkommunikation.getFlrkommunikationsart().getC_nr(); rows[row][col++] = partnerkommunikation.getC_bez(); rows[row][col++] = partnerkommunikation.getC_inhalt(); row++; col = 0; } result = new QueryResult(rows, 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; }