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


Java RowBounds.NO_ROW_OFFSET属性代码示例

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


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

示例1: selectPosts

@SuppressWarnings("unchecked")
public List<ActivityPostEntity> selectPosts(ActivityPostEntity activityPost, int maxItems) throws SQLException 
{
    int rowLimit = maxItems < 0 ? RowBounds.NO_ROW_LIMIT : maxItems;
    RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);
    
    if ((activityPost.getJobTaskNode() != -1) &&
        (activityPost.getMinId() != -1) &&
        (activityPost.getMaxId() != -1) &&
        (activityPost.getStatus() != null))
    {
        return template.selectList("alfresco.activities.select_activity_posts_by_params", activityPost, rowBounds);
    }
    else if (activityPost.getStatus() != null)
    {
        return template.selectList("alfresco.activities.select_activity_posts_by_status", activityPost, rowBounds);
    }
    else
    {
        return new ArrayList<ActivityPostEntity>(0);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ActivityPostDAOImpl.java

示例2: selectSiteFeedEntries

@SuppressWarnings("unchecked")
@Override
public List<ActivityFeedEntity> selectSiteFeedEntries(String siteId, int maxFeedSize) throws SQLException
{
    ActivityFeedQueryEntity params = new ActivityFeedQueryEntity();
    params.setSiteNetwork(siteId);
    
    int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize;
    RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);
    
    // for given site
    return template.selectList("alfresco.activities.select.select_activity_feed_for_site", params, rowBounds);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:ActivityFeedDAOImpl.java

示例3: processIntercept

void processIntercept(final Object[] queryArgs) {
	MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
	Object parameter = queryArgs[PARAMETER_INDEX];
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimit() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		if (dialect.supportsLimitOffset()) {
			sql = dialect.getLimitString(sql, offset, limit);
			offset = RowBounds.NO_ROW_OFFSET;
		} else {
			sql = dialect.getLimitString(sql, 0, limit);
		}
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(),
				boundSql.getParameterObject());
		for (ParameterMapping mapping : boundSql.getParameterMappings()) {
			String prop = mapping.getProperty();
			if (boundSql.hasAdditionalParameter(prop)) {
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:29,代码来源:PagePluging.java

示例4: intercept

@Override
public Object intercept(Invocation invocation) throws Throwable {
	final MappedStatement mappedStatement = (MappedStatement) invocation
			.getArgs()[0];
	// 拦截需要分页的SQL
	if (mappedStatement.getId().matches(SQL_PATTERN)) {
		Object parameter = invocation.getArgs()[1];
		BoundSql boundSql = mappedStatement.getBoundSql(parameter);
		String originalSql = boundSql.getSql().trim();
		if (null == boundSql.getSql() || "".equals(boundSql.getSql()))
			return null;
		// 分页参数--上下文传参
		Page page = null;
		PageContext context = PageContext.getPageContext();
		// map传参每次都将currentPage重置,先判读map再判断context
		if (null != parameter && null == context) {
			page = convertParameter(parameter, page);
		}
		// 分页参数--context参数里的Page传参
		if (null == page) {
			page = context;
		}

		if (null != page) {
			int totalPage = page.getTotal();
			// 得到总记录数
			if (totalPage == 0) {
				Connection connection = mappedStatement.getConfiguration()
						.getEnvironment().getDataSource().getConnection();
				totalPage = BaseParameter.getCount(originalSql, connection,
						mappedStatement, parameter, boundSql, DIALECT);
			}
			// 分页计算
			page.init(totalPage, page.getSize(), page.getLimit());
			invocation.getArgs()[2] = new RowBounds(
					RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
			BoundSql newBoundSql = new BoundSql(
					mappedStatement.getConfiguration(),
					BaseParameter.generatePageSql(originalSql, page,
							DIALECT), boundSql.getParameterMappings(),
					boundSql.getParameterObject());
			MappedStatement newMs = copyFromMappedStatement(
					mappedStatement, new BoundSqlSqlSource(newBoundSql));
			invocation.getArgs()[0] = newMs;
		}
	}
	PageContext.clear();
	return invocation.proceed();
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:49,代码来源:PaginationInterceptor.java

示例5: selectUserFeedEntries

@SuppressWarnings("unchecked")
@Override
public List<ActivityFeedEntity> selectUserFeedEntries(String feedUserId, String siteId, boolean excludeThisUser, boolean excludeOtherUsers, long minFeedId, int maxFeedSize) throws SQLException
{
    ActivityFeedQueryEntity params = new ActivityFeedQueryEntity();
    params.setFeedUserId(feedUserId);
    
    if (minFeedId > -1)
    {
        params.setMinId(minFeedId);
    }
    
    int rowLimit = maxFeedSize < 0 ? RowBounds.NO_ROW_LIMIT : maxFeedSize;
    RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);
    
    if (siteId != null)
    {
        // given site
        params.setSiteNetwork(siteId);
        
        if (excludeThisUser && excludeOtherUsers)
        {
            // effectively NOOP - return empty feed
            return new ArrayList<ActivityFeedEntity>(0);
        }
        if ((!excludeThisUser) && (!excludeOtherUsers))
        {
            // no excludes => everyone => where feed user is me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser_and_site", params, rowBounds);
        }
        else if ((excludeThisUser) && (!excludeOtherUsers))
        {
            // exclude feed user => others => where feed user is me and post user is not me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser_others_and_site", params, rowBounds);
        }
        else if ((excludeOtherUsers) && (!excludeThisUser))
        {
            // exclude others => me => where feed user is me and post user is me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser_me_and_site", params, rowBounds);
        }
    }
    else
    {
        // all sites
        
        if (excludeThisUser && excludeOtherUsers)
        {
            // effectively NOOP - return empty feed
            return new ArrayList<ActivityFeedEntity>(0);
        }
        if (!excludeThisUser && !excludeOtherUsers)
        {
            // no excludes => everyone => where feed user is me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser", params, rowBounds);
        }
        else if (excludeThisUser)
        {
            // exclude feed user => others => where feed user is me and post user is not me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser_others", params, rowBounds);
        }
        else if (excludeOtherUsers)
        {
            // exclude others => me => where feed user is me and post user is me
            return template.selectList("alfresco.activities.select.select_activity_feed_for_feeduser_me", params, rowBounds);
        }
    }
    
    // belts-and-braces
    throw new AlfrescoRuntimeException("Unexpected: invalid arguments");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:70,代码来源:ActivityFeedDAOImpl.java

示例6: intercept

public Object intercept(final Invocation invocation) throws Throwable {
       final Executor executor = (Executor) invocation.getTarget();
       final Object[] queryArgs = invocation.getArgs();
       final MappedStatement ms = (MappedStatement)queryArgs[MAPPED_STATEMENT_INDEX];
       final Object parameter = queryArgs[PARAMETER_INDEX];
       final RowBounds rowBounds = (RowBounds)queryArgs[ROWBOUNDS_INDEX];
       final PageBounds pageBounds = new PageBounds(rowBounds);

       if(pageBounds.getOffset() == RowBounds.NO_ROW_OFFSET
               && pageBounds.getLimit() == RowBounds.NO_ROW_LIMIT
               && pageBounds.getOrders().isEmpty()){
           return invocation.proceed();
       }

       final Dialect dialect;
       try {
           Class clazz = Class.forName(dialectClass);
           Constructor constructor = clazz.getConstructor(MappedStatement.class, Object.class, PageBounds.class);
           dialect = (Dialect)constructor.newInstance(new Object[]{ms, parameter, pageBounds});
       } catch (Exception e) {
           throw new ClassNotFoundException("Cannot create dialect instance: "+dialectClass,e);
       }

       final BoundSql boundSql = ms.getBoundSql(parameter);

       queryArgs[MAPPED_STATEMENT_INDEX] = copyFromNewSql(ms,boundSql,dialect.getPageSQL(), dialect.getParameterMappings(), dialect.getParameterObject());
       queryArgs[PARAMETER_INDEX] = dialect.getParameterObject();
       queryArgs[ROWBOUNDS_INDEX] = new RowBounds(RowBounds.NO_ROW_OFFSET,RowBounds.NO_ROW_LIMIT);

       Boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount();
       Future<List> listFuture = call(new Callable<List>() {
           public List call() throws Exception {
               return (List)invocation.proceed();
           }
       }, async);


       if(pageBounds.isContainsTotalCount()){
           Callable<Paginator> countTask = new Callable() {
               public Object call() throws Exception {
                   Integer count;
                   Cache cache = ms.getCache();
                   if(cache != null && ms.isUseCache() && ms.getConfiguration().isCacheEnabled()){
                       CacheKey cacheKey = executor.createCacheKey(ms,parameter,new PageBounds(),copyFromBoundSql(ms,boundSql,dialect.getCountSQL(), boundSql.getParameterMappings(), boundSql.getParameterObject()));
                       count = (Integer)cache.getObject(cacheKey);
                       if(count == null){
                           count = SQLHelp.getCount(ms,executor.getTransaction(),parameter,boundSql,dialect);
                           cache.putObject(cacheKey, count);
                       }
                   }else{
                       count = SQLHelp.getCount(ms,executor.getTransaction(),parameter,boundSql,dialect);
                   }
                   return new Paginator(pageBounds.getPage(), pageBounds.getLimit(), count);
               }
           };
           Future<Paginator> countFutrue = call(countTask, async);
           return new PageList(listFuture.get(),countFutrue.get());
       }

       return listFuture.get();
}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:61,代码来源:OffsetLimitInterceptor.java

示例7: processIntercept

void processIntercept(final Object[] queryArgs) throws Exception
{
	/*
	// 以下代码可根据数据源动态加载方言,用于多数据源的情况下
	Dialect dialect = this.dialect;
	String str = DynamicDataSource.getDbType();
	if(!str.equals("1"))
	{
		String dialectClass = this.properties.getProperty(str);
		try
		{
			System.out.println("dbType是" + str + ",加载动态方言:" + dialectClass);
			dialect = (Dialect) Class.forName(dialectClass).newInstance();
		}
		catch (Exception e)
		{
			throw new RuntimeException("无法初始化方言:" + dialectClass, e);
		}
	}
	*/
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimitOffset() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT))
	{
		MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
		Object parameter = queryArgs[PARAMETER_INDEX];
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		
		sql = dialect.getLimitString(sql, offset, limit);
		offset = RowBounds.NO_ROW_OFFSET;
		
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
		String prop;
		for(ParameterMapping p : boundSql.getParameterMappings())
		{
			prop = p.getProperty();
			if(boundSql.hasAdditionalParameter(prop))
			{
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:49,代码来源:OffsetLimitInterceptor.java


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