List of usage examples for org.hibernate Criteria setMaxResults
public Criteria setMaxResults(int maxResults);
From source file:com.algoTrader.entity.security.SecurityFamilyDaoBase.java
/** * {@inheritDoc}/*from w w w .j av a2s.c om*/ */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(SecurityFamilyImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.security.StockDaoBase.java
/** * {@inheritDoc}/*from www. j av a 2s . co m*/ */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(StockImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.security.StockOptionDaoBase.java
/** * {@inheritDoc}//from w w w. j a v a 2s. c o m */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(StockOptionImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.StrategyDaoBase.java
/** * {@inheritDoc}/*from w w w . j a v a 2s .c om*/ */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(StrategyImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.trade.TrailingStopOrderDaoBase.java
/** * {@inheritDoc}//from w w w .j a v a2s .c o m */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(TrailingStopOrderImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.TransactionDaoBase.java
/** * {@inheritDoc}// w w w .j av a2 s . c o m */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(TransactionImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.algoTrader.entity.WatchListItemDaoBase.java
/** * {@inheritDoc}/*from w w w. j a v a2s.c o m*/ */ @Override public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize) { try { final Criteria criteria = this.getSession(false).createCriteria(WatchListItemImpl.class); if (pageNumber > 0 && pageSize > 0) { criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize)); criteria.setMaxResults(pageSize); } final Collection<?> results = criteria.list(); this.transformEntities(transform, results); return results; } catch (HibernateException ex) { throw super.convertHibernateAccessException(ex); } }
From source file:com.apt.facade.AdminFacade.java
public List<Admin> getAdminList(int page, int pagesize) { List<Admin> lst = new ArrayList<>(); Session session = null;// w w w . j a v a2 s . c o m Transaction trans = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); trans = session.beginTransaction(); Criteria crit = session.createCriteria(Admin.class); crit.setMaxResults(pagesize); crit.setFirstResult((page - 1) * pagesize); lst = crit.list(); trans.commit(); } catch (Exception e) { e.printStackTrace(); if (trans != null) { trans.rollback(); } } finally { if (session != null && session.isConnected()) { session.close(); } } return lst; }
From source file:com.apt.facade.AdminFacade.java
public List<Admin> getAdminList(AdminFinder finder, int page, int recordPerPage) { List<Admin> lst = new ArrayList<>(); Session session = null;//w w w . j a v a2 s . co m Transaction trans = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); trans = session.beginTransaction(); Criteria crit = session.createCriteria(Admin.class); crit.add(Restrictions.sqlRestriction("1=1")); if (finder.getAdminID() != null) { crit.add(Restrictions.and(Restrictions.eq("adminID", finder.getAdminID()))); } if (finder.getAdminName() != null) { crit.add(Restrictions.and(Restrictions.ilike("adminName", "%" + finder.getAdminName() + "%"))); } if (finder.getStatus() != null) { crit.add(Restrictions.and(Restrictions.eq("status", finder.getStatus()))); } crit.setFirstResult((page - 1) * recordPerPage); crit.setMaxResults(recordPerPage); lst = crit.list(); trans.commit(); } catch (Exception e) { e.printStackTrace(); if (trans != null) { trans.rollback(); } } finally { if (session != null && session.isConnected()) { session.close(); } } return lst; }
From source file:com.apt.facade.AssignmentFacade.java
public List<Assignment> getAssignmentList(AssignmentFinder finder, int page, int recordPerPage) { List<Assignment> lst = new ArrayList<>(); Session session = null;//from w w w. ja v a 2 s . c o m Transaction trans = null; try { session = HibernateUtil.getSessionFactory().getCurrentSession(); trans = session.beginTransaction(); Criteria crit = session.createCriteria(Assignment.class); crit.add(Restrictions.sqlRestriction("1=1")); if (finder.getAssignmentId() != null) { crit.add(Restrictions.and(Restrictions.eq("assignmentId", finder.getAssignmentId()))); } if (finder.getAssignmentName() != null) { crit.add(Restrictions .and(Restrictions.ilike("assignmentName", "%" + finder.getAssignmentName() + "%"))); } if (finder.getBatch() != null) { crit.add(Restrictions.and(Restrictions.eq("batch", finder.getBatch()))); } if (finder.getSubject() != null) { crit.add(Restrictions.and(Restrictions.eq("subject", finder.getSubject()))); } if (finder.getStatus() != null) { crit.add(Restrictions.and(Restrictions.eq("status", finder.getStatus()))); } if (finder.getStarttime() != null) { crit.add(Restrictions.and(Restrictions.ge("startTime", finder.getStarttime()))); } if (finder.getEndtime() != null) { crit.add(Restrictions.and(Restrictions.le("endTime", finder.getEndtime()))); } crit.setFirstResult((page - 1) * recordPerPage); crit.setMaxResults(recordPerPage); lst = crit.list(); trans.commit(); } catch (Exception e) { e.printStackTrace(); if (trans != null) { trans.rollback(); } } finally { if (session != null && session.isConnected()) { session.close(); } } return lst; }