List of usage examples for org.hibernate Query setMaxResults
@Override
Query<R> setMaxResults(int maxResult);
From source file:com.lm.lic.manager.hibernate.LicenseDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<License> findUnusedProdLicenses(Long prodId) { List<License> licenses = null; try {/*from w w w . j a va2 s. co m*/ String qs = "from License as lic where lic.product.id= :prodId and lic.inUse=false" + ENABLED_AND_NOT_DELETED; Query hq = getSession().createQuery(qs); hq.setMaxResults(1); hq.setParameter("prodId", prodId); licenses = hq.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return licenses; }
From source file:com.lm.lic.manager.hibernate.LicenseDAO.java
License:Open Source License
@SuppressWarnings("unchecked") public List<License> findUnusedProdLicenses(Long prodId, Integer numLics) { List<License> licenses = null; try {// w w w .j a v a 2s. co m String qs = "from License as lic where lic.product.id= :prodId and lic.inUse=false " + ENABLED_AND_NOT_DELETED; Query hq = getSession().createQuery(qs); hq.setParameter("prodId", prodId); hq.setMaxResults(numLics); licenses = hq.list(); } catch (RuntimeException re) { log.error("findUnusedProdLicenses failed", re); throw re; } return licenses; }
From source file:com.lm.lic.manager.hibernate.ProductDAO.java
@SuppressWarnings("unchecked") public List<Product> findIsvProducts(Long isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) {//from w w w. j av a 2s . c o m List<Product> products = null; try { String qs = "from Product as prod where prod.isv.id= :isvId order by prod." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("isvId", isvId); products = query.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return products; }
From source file:com.lm.lic.manager.hibernate.ProductDAO.java
@SuppressWarnings("unchecked") public List<QuickyProduct> findAllIsvQuickyProducts(Long isvId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<QuickyProduct> products = null; try {//from w w w . java 2 s .c om String qs = "from QuickyProduct as qp where qp.isv.id= :isvId and deleted = false order by qp." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("isvId", isvId); products = query.list(); } catch (RuntimeException re) { log.error("find by property name failed", re); throw re; } return products; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public List<RequestForLicense> findProdRequests(Long prodId, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try {//from w w w. j a v a 2s .c o m String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); rfls = query.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> findProdGoodSales(Long prodId, String store, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try {//from ww w. j a v a 2 s . c om String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId and rfl.requestor= :requestor order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); query.setParameter("requestor", store); rfls = query.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> findProdBadSales(Long prodId, String store, List<QuickyProduct> products, Integer firstResult, Integer maxResults, String orderBy, String orderDir) { List<RequestForLicense> rfls = null; try {//from w ww. j a v a 2 s .c o m String qs = "from RequestForLicense as rfl where rfl.product.id= :prodId and rfl.requestor= :requestor " + "and rfl.response= :response order by rfl." + orderBy + " " + orderDir; Query query = getSession().createQuery(qs); query.setFirstResult(firstResult); query.setMaxResults(maxResults); query.setParameter("prodId", prodId); query.setParameter("requestor", store); query.setParameter("response", "InProgress"); rfls = query.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 RequestForLicense findByPinAndKey(String deviceId, String licKey) { RequestForLicense rfl = null;/*from w w w. j av a 2 s .c om*/ try { String qs = "from RequestForLicense as rfl where rfl.deviceId= :deviceId and :licKey in rfl.licKeys"; Query query = getSession().createQuery(qs); query.setParameter("deviceId", deviceId); query.setParameter("licKey", licKey); query.setMaxResults(1); List<RequestForLicense> rfls = query.list(); if (rfls != null && rfls.size() > 0) rfl = rfls.get(0); } catch (RuntimeException re) { log.error("findByPinAndKey failed", re); throw re; } return rfl; }
From source file:com.lm.lic.manager.hibernate.RequestForLicenseDAO.java
@SuppressWarnings("unchecked") public RequestForLicense findByDevIdProdId(String deviceId, Long prodId, String requestorIp) { RequestForLicense rfl = null;//from w ww . j a va2 s. co m try { String qs = "from RequestForLicense as rfl where rfl.deviceId= :deviceId and rfl.product.id= :prodId and " + "rfl.requestorIp= :requestorIp and rfl.numDeviceRequests > 0 and rfl.product.licLifeInDays < 365"; Query query = getSession().createQuery(qs); query.setParameter("deviceId", deviceId); query.setParameter("prodId", prodId); query.setParameter("requestorIp", requestorIp); query.setMaxResults(1); List<RequestForLicense> rfls = query.list(); if (rfls != null && rfls.size() > 0) rfl = rfls.get(0); } catch (RuntimeException re) { log.error("findByDevIdProdId failed", re); throw re; } return rfl; }
From source file:com.local.ask.model.controller.ModelDAOImpl.java
@Override public List<Question> getRecentForHottestQuestions() { List<Question> ret = new ArrayList<>(1000); try {/* w ww . j ava2 s . c o m*/ Query query = getCurrentSession().createQuery("FROM Question q ORDER BY q.timeLastViewed desc"); query.setMaxResults(1000); ret = query.list(); } catch (HibernateException ex) { ex.printStackTrace(); } return ret; }