List of usage examples for org.hibernate Criteria setFirstResult
public Criteria setFirstResult(int firstResult);
From source file:com.rajtech.stockwebservice.dao.Impl.PackDaoImpl.java
@Override public List<PackMaster> findByPage(int page, int no_of_record) { List<PackMaster> packMasters = null; if (page == 0) { page = 1;// w ww . ja v a 2s . c o m } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); packMasters = criteria.list(); return packMasters; }
From source file:com.rajtech.stockwebservice.dao.Impl.PurchaseDaoImpl.java
@Override public List<PurchaseMaster> findByPage(int page, int no_of_record) { List<PurchaseMaster> purchaseMasters = null; if (page == 0) { page = 1;/*w w w . j a va 2 s . com*/ } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); purchaseMasters = criteria.list(); return purchaseMasters; }
From source file:com.rajtech.stockwebservice.dao.Impl.SalesDaoImpl.java
@Override public List<SalesMaster> findByPage(int page, int no_of_record) { List<SalesMaster> salesMasters = null; if (page == 0) { page = 1;/* ww w. j a v a 2 s .c o m*/ } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); salesMasters = criteria.list(); return salesMasters; }
From source file:com.rajtech.stockwebservice.dao.Impl.StockImpl.java
@Override public List<ManufacturedStocks> findByPage(int page, int no_of_record) { List<ManufacturedStocks> manufacturedStockses = null; if (page == 0) { page = 1;//from w w w . j a v a 2 s.co m } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); manufacturedStockses = criteria.list(); return manufacturedStockses; }
From source file:com.rajtech.stockwebservice.dao.Impl.StockPackingDaoImpl.java
@Override public List<StockPacking> findByPage(int page, int no_of_record) { List<StockPacking> stockPackings = null; if (page == 0) { page = 1;// ww w . j a va2s . c o m } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); stockPackings = criteria.list(); return stockPackings; }
From source file:com.rajtech.stockwebservice.dao.Impl.TaxDaoImpl.java
@Override public List<Tax> findByPage(int page, int no_of_record) { List<Tax> taxs = null;// w ww. ja v a 2 s . com if (page == 0) { page = 1; } int indexPage = (page * no_of_record) - no_of_record; Criteria criteria = createEntityCriteria(); criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY); criteria.setFirstResult(indexPage); criteria.setMaxResults(no_of_record); taxs = criteria.list(); return taxs; }
From source file:com.rdsic.pcm.common.GenericDAO.java
@Override public List<T> list() { List<T> res = null;/*from w w w. j a v a 2 s. c o m*/ // make criteria of T Criteria criteria = getSession().createCriteria(getEntityClass()); // add Criterions if (crits != null) { for (Criterion crit : crits) { criteria.add(crit); } } // add orders if (orders != null) { for (Order ord : orders) { criteria.addOrder(ord); } } // paging if (firstResult >= 0) { criteria.setFirstResult(firstResult); } if (maxResult >= 0) { criteria.setMaxResults(maxResult); } // make result res = criteria.list(); // and clear all params, next command must set again clearParams(); if (res == null) { res = new ArrayList<T>(); } return res; }
From source file:com.restful.api.resteasy.dao.FeatureDAO.java
public List<Feature> getFeatures(Integer length, Integer start, String column, String dir, String value) { List<Feature> features = null; Session session = null;/*w w w. j a v a2 s .c om*/ try { session = HibernateUtil.getSessionFactory().openSession(); Criteria crit = session.createCriteria(Feature.class); if (value != null) { Criterion v1 = Restrictions.like("rendering_engine", "%" + value + "%"); Criterion v3 = Restrictions.like("browser", "%" + value + "%"); Criterion v4 = Restrictions.like("platform", "%" + value + "%"); Criterion v5 = Restrictions.like("engine_version", "%" + value + "%"); Criterion v6 = Restrictions.like("css_grade", "%" + value + "%"); crit.add(Restrictions.or(v1, v3, v4, v5, v6)); } if (dir != null && column != null) { if ("desc".equals(dir.toLowerCase())) { crit.addOrder(Order.desc(column));//?? } else { crit.addOrder(Order.asc(column));//?? } } if (length > 0) { crit.setMaxResults(length); } if (start > 0) { crit.setFirstResult(start); } features = crit.list(); } catch (Exception ex) { Logger.getLogger(Feature.class.getName()).log(Level.SEVERE, null, ex); } finally { if (session != null) { session.close(); } } return features; }
From source file:com.rockagen.gnext.dao.hb.Hibernate4GenericDaoImpl.java
License:Apache License
/** * Create a hibernate {@link Criteria} by {@link DetachedCriteria} * // w ww. ja va 2s. co m * @param criterions * @param firstResult * @param maxResults * negatives meaning no limit... * @return Criteria */ protected Criteria createCriteria(DetachedCriteria dcriteria, int firstResult, int maxResults) { if (dcriteria == null) { dcriteria = DetachedCriteria.forClass(getEntityClass()); } Criteria criteria = dcriteria.getExecutableCriteria(super.getSession()); if (firstResult > 0) { criteria.setFirstResult(firstResult); } if (maxResults > 0) { criteria.setMaxResults(maxResults); } return criteria; }
From source file:com.romeikat.datamessie.core.base.dao.impl.AbstractEntityDao.java
License:Open Source License
/** * Provides all entities.//from w w w .j a v a2s .c o m * * @param ssc * @return */ @Override public List<E> getEntites(final SharedSessionContract ssc, final Integer firstResult, final Integer maxResults) { // Query final Criteria criteria = ssc.createCriteria(entityClass); final String defaultSortingProperty = defaultSortingProperty(); if (defaultSortingProperty != null) { criteria.addOrder(Order.asc(defaultSortingProperty)); } if (firstResult != null) { criteria.setFirstResult(firstResult); } if (maxResults != null) { criteria.setMaxResults(maxResults); } // Done @SuppressWarnings("unchecked") final List<E> entities = criteria.list(); return entities; }