当前位置: 首页>>代码示例>>Java>>正文


Java Criteria.setMaxResults方法代码示例

本文整理汇总了Java中org.hibernate.Criteria.setMaxResults方法的典型用法代码示例。如果您正苦于以下问题:Java Criteria.setMaxResults方法的具体用法?Java Criteria.setMaxResults怎么用?Java Criteria.setMaxResults使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.hibernate.Criteria的用法示例。


在下文中一共展示了Criteria.setMaxResults方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAppsOfDropMarket

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<App> getAppsOfDropMarket(Session session, String marketName, Integer currentPage, Integer pageSize) {
    ProjectionList proList = Projections.projectionList();
    proList.add(Projections.property("pkname"));
    proList.add(Projections.property("signatureSha1"));
    Criteria cri = session.createCriteria(App.class);
    cri.setProjection(proList);
    cri.setMaxResults(pageSize);
    cri.setFirstResult(HibernateHelper.firstResult(currentPage, pageSize));
    List<Object[]> list = HibernateHelper.list(cri);
    List<App> apps = null;
    if (list != null) {
        apps = new ArrayList<App>(list.size());
        for (Object[] obj : list) {
            App e = new App();
            e.setPkname((String) obj[0]);
            e.setSignatureSha1((String) obj[1]);
            apps.add(e);
        }
        list.clear();
    }
    return apps;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:24,代码来源:AppDaoImpl.java

示例2: search

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<MarketApp> search(EnumMarket enumMarket, Short catalog, Integer subCatalog, int page, int rows,
        String keywords, String sort, String order) {
    Criteria cri = searchByFilter(enumMarket, catalog, subCatalog, keywords);

    if (sort != null && !sort.isEmpty()) {
        HibernateHelper.addOrder(cri, sort, order);
    } else {
        if (order != null && "asc".equals(order)) {
            cri.addOrder(Order.asc("id"));
        } else {
            cri.addOrder(Order.desc("id"));
        }
    }
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<MarketApp> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:20,代码来源:MarketAppDaoImpl.java

示例3: listUserByPage

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public Pager<User> listUserByPage(int pageNo, int pageSize) {
	Session session = sessionFactory.getCurrentSession();
	Criteria criteria = session.createCriteria(User.class);
	long recordTotal = ((Long) criteria.setProjection(Projections.rowCount()).uniqueResult()).longValue();
	criteria.setProjection(null);
	criteria.addOrder(Order.desc("registerDate"));
	criteria.setFirstResult((pageNo - 1) * pageSize);
	criteria.setMaxResults(pageSize);
	List<User> results = criteria.list();
	return new Pager<User>(pageSize, pageNo, recordTotal, results);
}
 
开发者ID:zhangjikai,项目名称:sdudoc,代码行数:13,代码来源:UserDaoImpl.java

示例4: prepareCriteria

import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
 * Prepare the given Criteria object, applying cache settings and/or
 * a transaction timeout.
 * @param criteria the Criteria object to prepare
 * @see #setCacheQueries
 * @see #setQueryCacheRegion
 */
protected void prepareCriteria(Criteria criteria) {
	if (isCacheQueries()) {
		criteria.setCacheable(true);
		if (getQueryCacheRegion() != null) {
			criteria.setCacheRegion(getQueryCacheRegion());
		}
	}
	if (getFetchSize() > 0) {
		criteria.setFetchSize(getFetchSize());
	}
	if (getMaxResults() > 0) {
		criteria.setMaxResults(getMaxResults());
	}

	SessionHolder sessionHolder =
			(SessionHolder) TransactionSynchronizationManager.getResource(getSessionFactory());
	if (sessionHolder != null && sessionHolder.hasTimeout()) {
		criteria.setTimeout(sessionHolder.getTimeToLiveInSeconds());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HibernateTemplate.java

示例5: searchForRolling

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<Rollinfo> searchForRolling(Short catalog, Integer subCatalog, int page, int rows, String keywords,
        String sort, String order) {
    Criteria cri = getSession().createCriteria(Rollinfo.class);
    Criteria appCriteria = cri.createCriteria("app", JoinType.LEFT_OUTER_JOIN);
    if (catalog != null) {
        appCriteria.add(Restrictions.eq("catalog", catalog));
    }
    if (subCatalog != null) {
        appCriteria.add(Restrictions.eq("subCatalog", subCatalog));
    }

    if (keywords != null && !keywords.isEmpty()) {
        appCriteria.add(Restrictions.like("name", keywords, MatchMode.ANYWHERE));
    }

    if (sort != null && !sort.isEmpty()) {
        HibernateHelper.addOrder(appCriteria, sort, order);
    }
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<Rollinfo> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:25,代码来源:AppDaoImpl.java

示例6: search

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<MoViewTagApps> search(Integer tagId, Integer catalog, Short tagType, int page, int rows,
        String keywords, String sort, String order) {
    Criteria cri = searchByFilter(tagId, catalog, tagType, keywords);
    if (sort != null && !sort.isEmpty()) {
        HibernateHelper.addOrder(cri, sort, order);
    } else {
        if (order != null && "asc".equals(order)) {
            cri.addOrder(Order.asc("id"));
        } else {
            cri.addOrder(Order.desc("id"));
        }
    }
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<MoViewTagApps> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:19,代码来源:MoAppAndTagDaoImpl.java

示例7: findByExample

import org.hibernate.Criteria; //导入方法依赖的package包/类
public <T> List<T> findByExample(final String entityName, final T exampleEntity, final int firstResult,
    final int maxResults) {

if (exampleEntity == null) {
    throw new IllegalArgumentException("Example entity must not be null");
}

Criteria executableCriteria = (entityName != null ? getSession().createCriteria(entityName)
	: getSession().createCriteria(exampleEntity.getClass()));
executableCriteria.add(Example.create(exampleEntity));
if (firstResult >= 0) {
    executableCriteria.setFirstResult(firstResult);
}
if (maxResults > 0) {
    executableCriteria.setMaxResults(maxResults);
}
return executableCriteria.list();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:LAMSBaseDAO.java

示例8: execute

import org.hibernate.Criteria; //导入方法依赖的package包/类
private Object execute(FlowFinderCriteria flowFinderCriteria,
        DetachedCriteria flowStatusCriteria, Session session,
        boolean idProjection) {

    Criteria criteria = flowStatusCriteria.getExecutableCriteria(session);

    if (idProjection) {
        criteria.setProjection(Projections.id());
    }
    
    int maxResults = flowFinderCriteria.getMaxResults();
    if (maxResults != FlowFinderCriteria.DEFAULT_MAX_RESULTS) {
        criteria.setMaxResults(maxResults);
    }

    if (flowFinderCriteria.hasMessageQuery()) {
        FlowSearchCriteria flowSearchCriteria = new FlowSearchCriteria();
        flowSearchCriteria.setHibernateCriteria(criteria);
        flowSearchCriteria.setInboundMessageQuery(flowFinderCriteria.getInboundMessageQuery());
        flowSearchCriteria.setOutboundMessageQuery(flowFinderCriteria.getOutboundMessageQuery());
        return flowSearchCallback.findFlows(session, flowSearchCriteria);
    } else {
        return criteria.list();
    }
}
 
开发者ID:oehf,项目名称:ipf-flow-manager,代码行数:26,代码来源:FlowRepositoryImpl.java

示例9: setPageRequestToCriteria

import org.hibernate.Criteria; //导入方法依赖的package包/类
/**
 * 设置分页参数到Criteria对象,辅助函数.
 */
protected Criteria setPageRequestToCriteria(final Criteria c, final PageRequest pageRequest) {
	AssertUtils.isTrue(pageRequest.getPageSize() > 0, "Page Size must larger than zero");
	
	c.setFirstResult(pageRequest.getOffset());
	c.setMaxResults(pageRequest.getPageSize());

	if (pageRequest.isOrderBySetted()) {
		for (PageRequest.Sort sort : pageRequest.getSort()) {
			if (PageRequest.Sort.ASC.equals(sort.getDir())) {
				c.addOrder(Order.asc(sort.getProperty()));
			} else {
				c.addOrder(Order.desc(sort.getProperty()));
			}
		}
	}
	return c;
}
 
开发者ID:wkeyuan,项目名称:DWSurvey,代码行数:21,代码来源:HibernateDao.java

示例10: pageByConditions

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Transactional(readOnly = true, rollbackFor = Exception.class)
public Pagination<JobDetailDO> pageByConditions(Integer pageIndex, Integer pageSize, String desc, Integer state) {
    Criteria criteria = daoSupport.createCriteria(JobDetailDO.class);
    if (!StringUtils.isEmpty(desc)) {
        criteria.add(Restrictions.like("description", "%" + desc + "%"));
    }
    if (state != 0) {
        criteria.add(Restrictions.eq("state", state));
    }
    //先获取总记录数
    Long totalCount = (Long) criteria.setProjection(Projections.count("id")).uniqueResult();

    criteria.setProjection(null);
    criteria.setFirstResult((pageIndex - 1) * pageSize);
    criteria.setMaxResults(pageIndex * pageSize);
    List items = criteria.list();

    Pagination<JobDetailDO> pagination = new Pagination<JobDetailDO>(pageIndex.longValue(), pageSize.longValue(), totalCount);
    pagination.setItems(items);
    return pagination;
}
 
开发者ID:wu05281,项目名称:admin-shiro,代码行数:22,代码来源:JobDetailService.java

示例11: search

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<MoTag> search(Short pId, String keywords, int page, int rows, String sort, String order) {
    // 查询条件
    Criteria cri = searchByFilter(pId, keywords);
    // 查询排序
    searchSort(sort, order, cri);
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<MoTag> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:12,代码来源:MoTagDaoImpl.java

示例12: queryUserList

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<User> queryUserList(int page, int rows, String keyword, String order, String sort) {
    // 查询条件
    Criteria cri = searchByFilter(keyword);
    // 查询排序
    searchSort(sort, order, cri);
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<User> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:12,代码来源:UserDaoImpl.java

示例13: search

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<Catalog> search(short catalog, int subCatalog, String keywords, int page, int rows, String sort,
        String order) {
    // 查询条件
    Criteria cri = searchByFilter(catalog, subCatalog, keywords);
    // 查询排序
    searchSort(sort, order, cri);
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<Catalog> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:CatalogDaoImpl.java

示例14: search

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<MoMixFeatured> search(Short type, Short picType, Boolean hidden, String keywords, int page, int rows,
        String sort, String order) {
    // 查询条件
    Criteria cri = searchByFilter(type, picType, hidden, keywords);
    // 查询排序
    searchSort(sort, order, cri);
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<MoMixFeatured> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:13,代码来源:MoMixFeaturedDaoImpl.java

示例15: queryList

import org.hibernate.Criteria; //导入方法依赖的package包/类
@Override
public List<MonUserChannelApp> queryList(String keyword, Boolean autCover, int page, int rows, String order,
        String sort) {
    Criteria cri = searchByFilter(keyword, autCover);
    // 查询排序
    searchSort(sort, order, cri);
    cri.setMaxResults(rows);
    cri.setFirstResult(HibernateHelper.firstResult(page, rows));
    List<MonUserChannelApp> list = HibernateHelper.list(cri);
    return list;
}
 
开发者ID:zhaoxi1988,项目名称:sjk,代码行数:12,代码来源:MonUserChannelAppDaoImpl.java


注:本文中的org.hibernate.Criteria.setMaxResults方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。