Example usage for org.hibernate Criteria setMaxResults

List of usage examples for org.hibernate Criteria setMaxResults

Introduction

In this page you can find the example usage for org.hibernate Criteria setMaxResults.

Prototype

public Criteria setMaxResults(int maxResults);

Source Link

Document

Set a limit upon the number of objects to be retrieved.

Usage

From source file:com.lm.lic.manager.hibernate.LicenseDAO.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<License> findInUseIsvProdTrialLicenses(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 {/*  ww  w. j a  v a  2  s. c  om*/
        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.add(Restrictions.eq("decom", false));
        mainCriteria.add(Restrictions.lt("lifeInDays", 365));

        mainCriteria.setFirstResult(firstResult);
        mainCriteria.setMaxResults(maxResults);

        addOrderByToCriteria(orderBy, orderDir, mainCriteria, prodInstCriterias);

        licenses = mainCriteria.list();

    } catch (RuntimeException re) {
        log.error("findInUseIsvProdTrialLicenses 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> 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.  ja v  a2  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) {/*w  ww.  j  a  va  2 s.  c o m*/
    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 {//from  w  ww.ja  v a  2  s .  com
        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 {/*  www . j ava2s .  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 {/*  w  ww  .ja  v  a 2  s.  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 www  .  ja va 2  s .  com
    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 {/*from   w  ww  .j  av  a 2s.  c om*/
        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  ww.  jav a 2s  .c  om*/
    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.lp.server.artikel.ejbfac.ArtikelFacBean.java

License:Open Source License

public boolean sindVorschlagstexteVorhanden() {
    Session session = FLRSessionFactory.getFactory().openSession();
    Criteria c = session.createCriteria(FLRVorschlagstext.class);
    c.setMaxResults(1);
    List<?> l = c.list();/*from  ww  w. j a v a  2 s.c om*/

    if (l.size() > 0) {
        return true;
    } else {
        return false;
    }

}