List of usage examples for org.hibernate Criteria setFirstResult
public Criteria setFirstResult(int firstResult);
From source file:com.lm.lic.manager.hibernate.LicenseDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<License> findIssuedLicenses(String isvId, String prodId, String prodDefId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<License> licenses = null; try {// w w w. j a v a 2 s . c o m Criteria mainCriteria = getSession().createCriteria(License.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); addDateRangeRestrictions(TIME_ACTIVATED, startDate, endDate, mainCriteria); mainCriteria.add(Restrictions.eq("inUse", true)); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); licenses = mainCriteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return licenses; }
From source file:com.lm.lic.manager.hibernate.LicenseVerifIncidentDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<LicenseVerifIncident> findIsvVerifs(Long isvId, String licType, String respType, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) {//from w w w. ja v a 2 s .c om List<LicenseVerifIncident> rfls = null; try { Criteria mainCriteria = getSession().createCriteria(LicenseVerifIncident.class); mainCriteria.add(Restrictions.eq("isv.id", isvId)); Criteria prodCriteria = addEnabledUnDeletedProductCriteria(mainCriteria); addLicTypeRespTypeCrit(licType, respType, mainCriteria, prodCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); if (startDate != null && endDate != null) mainCriteria.add(Restrictions.between(TIME_REQUESTED, startDate, endDate)); else { if (startDate != null) mainCriteria.add(Restrictions.gt(TIME_REQUESTED, startDate)); if (endDate != null) mainCriteria.add(Restrictions.lt(TIME_REQUESTED, endDate)); } createOrderByFieldAliasIfApplicable(orderBy, orderDir, mainCriteria, prodCriteria); rfls = mainCriteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; }
From source file:com.lm.lic.manager.hibernate.LicenseVerifIncidentDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<LicenseVerifIncident> findProdVerifs(String isvId, String prodId, String prodDefId, String storeId, String platformId, String licType, String respType, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<LicenseVerifIncident> lvis = null; try {// w ww . java 2s . c om Criteria mainCriteria = getSession().createCriteria(LicenseVerifIncident.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); Criteria prodCriteria = prodInstCriterias.getProdCriteria(); addLicTypeRespTypeCrit(licType, respType, mainCriteria, prodCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); lvis = mainCriteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return lvis; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findIsvRequests(Long isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try {/*from w w w . ja v a 2 s .co m*/ Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("isv.id", isvId)); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findIsvProdRequests(String isvId, String prodId, String prodDefId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> rfls = null; try {/*from w w w . ja va 2s. c o m*/ Criteria mainCriteria = getSession().createCriteria(RequestForLicense.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); rfls = mainCriteria.list(); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } return rfls; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findIsvGoodSales(String isvId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) {/*from w w w . j a va 2s .c om*/ List<RequestForLicense> rfls = null; try { Criteria criteria = createCriteriaForClass(RequestForLicense.class); addIsvProductInstProductDefStorePlatfrmCriteria(isvId, null, null, storeId, platformId, criteria); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findIsvProdGoodSales(String isvId, String prodId, String prodDefId, String storeId, String platformId, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) { List<RequestForLicense> sales = null; try {/* ww w. ja v a2 s.c o m*/ Criteria mainCriteria = createCriteriaForClass(RequestForLicense.class); ProductInstanceCriterias prodInstCriterias = addIsvProductInstProductDefStorePlatfrmCriteria(isvId, prodId, prodDefId, storeId, platformId, mainCriteria); mainCriteria.setFirstResult(firstResult); mainCriteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, mainCriteria); // createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias); sales = mainCriteria.list(); } catch (Exception e) { log.error("find by property name failed", e); throw new RuntimeException(e); } return sales; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findIsvBadSales(Long isvId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir, Date startDate, Date endDate) {// w w w .ja v a2 s. co m List<RequestForLicense> rfls = null; try { Criteria criteria = getSession().createCriteria(RequestForLicense.class); criteria.add(Restrictions.eq("requestor", store)); criteria.add(Restrictions.eq("response", "InProgress")); LogicalExpression orExp = createInProdNamesOrIsvProdIdsLogicalExp(products); if (orExp != null) criteria.add(orExp); criteria.setFirstResult(firstResult); criteria.setMaxResults(maxResults); addDateRangeRestrictions(TIME_REQUESTED, startDate, endDate, criteria); createOrderByFieldAliasIfApplicable(orderBy, orderDir, criteria); rfls = criteria.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return rfls; }
From source file:com.lushapp.common.orm.hibernate.HibernateDao.java
License:Apache License
/** * ?Criteria,.//from ww w. j a v a 2 s . c om */ protected Criteria setPageParameterToCriteria(final Criteria c, final Page<T> page) { Assert.isTrue(page.getPageSize() > 0, "Page Size must larger than zero"); // hibernatefirstResult??0 c.setFirstResult(page.getFirst() - 1); c.setMaxResults(page.getPageSize()); //? super.setPageParameterToCriteria(c, page.getOrderBy(), page.getOrder()); return c; }
From source file:com.lyh.licenseworkflow.dao.EnhancedHibernateDaoSupport.java
/** * //from ww w . j a va 2s . co m * * @param start ? - 0 * @param pageSize ?? * @return */ @SuppressWarnings("unchecked") public List<T> getPagingEntities(final int start, final int pageSize) { return (List<T>) getHibernateTemplate().execute(new HibernateCallback() { public Object doInHibernate(Session session) throws HibernateException, SQLException { Criteria criteria = session.createCriteria(getEntityName()); criteria.setFirstResult(start); criteria.setMaxResults(pageSize); return criteria.list(); } }); }