文档章节

ibatis 查询超多数量报 SQLException MaxRowCount

philonic
 philonic
发布于 2017/03/24 14:21
字数 640
阅读 263
收藏 0

Ibatis有地方配置这个MaxRowCount 属性,如果超过数量就或报错或抓取数据异常 看如下配置例子:

<bean id="sqlMapClient"
		class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
		<property name="configLocation">
			<description>
				iBATIS SQL Mapping配置文件名,系统要能够在CLASSPATH中找到该文件
			</description>
			<value>sqlmap-config.xml</value>
		</property>
		<property name="maxRowCount">
			<description>iBATIS 查询数据库的最大数据库记录行数</description>
			<value>${ibatis.query.maxrowcount}</value>
		</property>
		<property name="excludeStatements">
			<description>
				不需要限制结果集的语句
			</description>
			<list>
				<value>searchPolicyByCriteria</value>
			</list>
		</property>

		<property name="maxRowCount4Excludes">
			<description>
				excludeStatements中的sql查询数据库的最大记录行数.
				默认为10000
			</description>
			<value>${ibatis.maxRowCount4Excludes.num}</value>
		</property>

		<property name="isThrowExcept">
			<description>iBATIS 查询数据超过最大行数限制后是否抛出异常</description>
			<value>true</value>
		</property>
	</bean>

ibatis查询报错信息如下:

[03/24 14:05:34] [WARN] PafaSqlExecutor:  getMoreCount : result has exceeded the maxRowCount limit! The MaxRowCount is 10000.
[03/24 14:05:34] [INFO] XmlBeanDefinitionReader:  Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
[03/24 14:05:34] [INFO] SQLErrorCodesFactory:  SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
[03/24 14:05:34] [ERROR] CommonDAOImpl:  queryList
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [null]; error code [0];   
--- The error occurred in sqlmap-mapping-dams-test.xml.  
--- The error occurred while applying a result map.  
--- Check the getMoreCount-AutoResultMap.  
--- Check the result mapping for the 'dept_code' property.  
--- Cause: java.sql.SQLException: result has exceeded the maxRowCount limit! The MaxRowCount is 10000; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlmap-mapping-dams-test.xml.  
--- The error occurred while applying a result map.  
--- Check the getMoreCount-AutoResultMap.  
--- Check the result mapping for the 'dept_code' property.  
--- Cause: java.sql.SQLException: result has exceeded the maxRowCount limit! The MaxRowCount is 10000
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:203)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:293)
	at com.biz.dao.BaseDAO._queryForList(Unknown Source)
	at com.common.dao.impl.CommonDAOImpl.queryList(CommonDAOImpl.java:52)
	at com.common.service.impl.CommonServiceImpl.queryForList(CommonServiceImpl.java:72)
	at com.yxd.biz.service.SynDeptServiceTest.testTresd(SynDeptServiceTest.java:360)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlmap-mapping-dams-test.xml.  
--- The error occurred while applying a result map.  
--- Check the getMoreCount-AutoResultMap.  
--- Check the result mapping for the 'dept_code' property.  
--- Cause: java.sql.SQLException: result has exceeded the maxRowCount limit! The MaxRowCount is 10000
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForList(GeneralStatement.java:123)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:615)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:589)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
	at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:295)
	at org.springframework.orm.ibatis.SqlMapClientTemplate$3.doInSqlMapClient(SqlMapClientTemplate.java:1)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:200)
	... 29 more
Caused by: java.sql.SQLException: result has exceeded the maxRowCount limit! The MaxRowCount is 10000
	at com.app.lwc.service.persistence.dao.ibatis.PafaSqlExecutor.handleResults(Unknown Source)
	at com.app.lwc.service.persistence.dao.ibatis.PafaSqlExecutor.executeQuery(Unknown Source)
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.sqlExecuteQuery(GeneralStatement.java:205)
	at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:173)

看这个配置说明,很明白了吧。 在excludeStatements的list中添加自己的SQL id,并且配置maxRowCount4Exclude大于查询总数就可以了。(或者注掉maxRowCount4Exclude代码)。

© 著作权归作者所有

philonic

philonic

粉丝 4
博文 34
码字总数 71311
作品 0
后端工程师
私信 提问
ibatis抽风了咋搞哦

就是在UserBasicInfo这个实体类里面加了个扩展属性,跟表不想关的,结果ibatis就报这个操蛋的问题,咋整都没用。然后又试了下,换了个另外的实体类加一个属性,还是报这样的错误,不过Class...

开源中国老嫖客
2017/04/14
195
5
使用 ibatis 处理复杂对象数据关系的实例

ibatis 基本介绍 起源于 2001 年的开放源代码项目 ibatis,是一个基于 Java 的持久层框架。与 Hibernate, Toplink 等持久化框架不同,ibatis 是一个 “半自动化”的 ORM 实现。ibatis 没有对...

红薯
2010/09/05
1K
4
深入分析 iBATIS 框架之系统架构与映射原理

简介: iBATIS 通过 SQL Map 将 Java 对象映射成 SQL 语句和将结果集再转化成 Java 对象,与其他 ORM 框架相比,既解决了 Java 对象与输入参数和结果集的映射,又能够让用户方便的手写使用 ...

老盖
2010/11/11
2.2K
3
关于 spring ibatis多数据源问题

配置在这里就不多说了,基本在网上搜得一样, 项目启动后一旦访问数据库后,没几分钟就报异常,如下 Caused by: com.ibatis.common.jdbc.exception.NestedSQLException: --- The error occu...

樱花泪
2016/01/25
425
2
iBATIS 3.0 GA (Candidate) 发布

官网上写着 GA 后面又跟着一个 Candidate ,不知何意? iBATIS 3.0 GA (Candidate) 发布了,这个版本经过了1年多,10个beta版本的测试。 iBATIS一词来源于“internet”和“abatis”的组合,是...

zhuzhangsuo
2010/04/19
2.6K
5

没有更多内容

加载失败,请刷新页面

加载更多

Angular 英雄编辑器

应用程序现在有了基本的标题。 接下来你要创建一个新的组件来显示英雄信息并且把这个组件放到应用程序的外壳里去。 创建英雄组件 使用 Angular CLI 创建一个名为 heroes 的新组件。 ng gener...

honeymoose
今天
4
0
Kernel DMA

为什么会有DMA(直接内存访问)?我们知道通常情况下,内存数据跟外设之间的通信是通过cpu来传递的。cpu运行io指令将数据从内存拷贝到外设的io端口,或者从外设的io端口拷贝到内存。由于外设...

yepanl
今天
6
0
hive

一、hive的定义: Hive是一个SQL解析引擎,将SQL语句转译成MR Job,然后再在Hadoop平台上运行,达到快速开发的目的 Hive中的表是纯逻辑表,就只是表的定义,即表的元数据。本质就是Hadoop的目...

霉男纸
今天
3
0
二、Spring Cloud—Eureka(Greenwich.SR1)

注:本系列文章所用工具及版本如下:开发工具(IDEA 2018.3.5),Spring Boot(2.1.3.RELEASE),Spring Cloud(Greenwich.SR1),Maven(3.6.0),JDK(1.8) Eureka: Eureka是Netflix开发...

倪伟伟
昨天
13
0
eclipse常用插件

amaterasUML https://takezoe.github.io/amateras-update-site/ https://github.com/takezoe/amateras-modeler modelGoon https://www.cnblogs.com/aademeng/articles/6890266.html......

大头鬼_yc
昨天
5
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部