mybatis <fireach> 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause:
<select id="getUserIn" parameterType="QueryVo" resultMap="userMap">
		SELECT
		<!-- 引用sql片段 -->
		<include refid="user_sql" />
		  FROM USER
		    <where>
			      <!-- 遍历pojo传入的集合
collection="in" 要遍历pojo对象属性名不能是in 否则报错
      -->
			      <foreach collection="ids" item="item" index="index" open="id in(" separator="," close=")">
        #{item}
			      </foreach>
		    </where>
	  </select>
异常信息:
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: in [org.apache.ibatis.ognl.ParseException: Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    ":" ...
    "not" ...
    "+" ...
    "-" ...
    "~" ...
    "!" ...
    "(" ...
    "true" ...
    "false" ...
    "null" ...
    "#this" ...
    "#root" ...
    "#" ...
    "[" ...
    "{" ...
    "@" ...
    "new" ...
    <IDENT> ...
    <DYNAMIC_SUBSCRIPT> ...
    "\'" ...
    "`" ...
    "\"" ...
    <INT_LITERAL> ...
    <FLT_LITERAL> ...
    ]
### Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: in [org.apache.ibatis.ognl.ParseException: Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    ":" ...
    "not" ...
    "+" ...
    "-" ...
    "~" ...
    "!" ...
    "(" ...
    "true" ...
    "false" ...
    "null" ...
    "#this" ...
    "#root" ...
    "#" ...
    "[" ...
    "{" ...
    "@" ...
    "new" ...
    <IDENT> ...
    <DYNAMIC_SUBSCRIPT> ...
    "\'" ...
    "`" ...
    "\"" ...
    <INT_LITERAL> ...
    <FLT_LITERAL> ...
    ]
	at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:150)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)
	at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
	at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
	at com.sun.proxy.$Proxy6.getUserIn(Unknown Source)
	at cool.zsn.UserDao.Test.UserDaoTest.getUserIn(UserDaoTest.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: in [org.apache.ibatis.ognl.ParseException: Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    ":" ...
    "not" ...
    "+" ...
    "-" ...
    "~" ...
    "!" ...
    "(" ...
    "true" ...
    "false" ...
    "null" ...
    "#this" ...
    "#root" ...
    "#" ...
    "[" ...
    "{" ...
    "@" ...
    "new" ...
    <IDENT> ...
    <DYNAMIC_SUBSCRIPT> ...
    "\'" ...
    "`" ...
    "\"" ...
    <INT_LITERAL> ...
    <FLT_LITERAL> ...
    ]
	at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:46)
	at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateIterable(ExpressionEvaluator.java:43)
	at org.apache.ibatis.scripting.xmltags.ForEachSqlNode.apply(ForEachSqlNode.java:55)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
	at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:55)
	at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
	at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41)
	at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292)
	at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)
	... 29 more
Caused by: org.apache.ibatis.ognl.ExpressionSyntaxException: Malformed OGNL expression: in [org.apache.ibatis.ognl.ParseException: Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    ":" ...
    "not" ...
    "+" ...
    "-" ...
    "~" ...
    "!" ...
    "(" ...
    "true" ...
    "false" ...
    "null" ...
    "#this" ...
    "#root" ...
    "#" ...
    "[" ...
    "{" ...
    "@" ...
    "new" ...
    <IDENT> ...
    <DYNAMIC_SUBSCRIPT> ...
    "\'" ...
    "`" ...
    "\"" ...
    <INT_LITERAL> ...
    <FLT_LITERAL> ...
    ]
	at org.apache.ibatis.ognl.Ognl.parseExpression(Ognl.java:112)
	at org.apache.ibatis.scripting.xmltags.OgnlCache.parseExpression(OgnlCache.java:53)
	at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:44)
	... 38 more
Caused by: org.apache.ibatis.ognl.ParseException: Encountered " "in" "in "" at line 1, column 1.
Was expecting one of:
    ":" ...
    "not" ...
    "+" ...
    "-" ...
    "~" ...
    "!" ...
    "(" ...
    "true" ...
    "false" ...
    "null" ...
    "#this" ...
    "#root" ...
    "#" ...
    "[" ...
    "{" ...
    "@" ...
    "new" ...
    <IDENT> ...
    <DYNAMIC_SUBSCRIPT> ...
    "\'" ...
    "`" ...
    "\"" ...
    <INT_LITERAL> ...
    <FLT_LITERAL> ...
at org.apache.ibatis.ognl.OgnlParser.generateParseException(OgnlParser.java:3172)
	at org.apache.ibatis.ognl.OgnlParser.jj_consume_token(OgnlParser.java:3051)
	at org.apache.ibatis.ognl.OgnlParser.unaryExpression(OgnlParser.java:1236)
	at org.apache.ibatis.ognl.OgnlParser.multiplicativeExpression(OgnlParser.java:971)
	at org.apache.ibatis.ognl.OgnlParser.additiveExpression(OgnlParser.java:894)
	at org.apache.ibatis.ognl.OgnlParser.shiftExpression(OgnlParser.java:750)
	at org.apache.ibatis.ognl.OgnlParser.relationalExpression(OgnlParser.java:508)
	at org.apache.ibatis.ognl.OgnlParser.equalityExpression(OgnlParser.java:405)
	at org.apache.ibatis.ognl.OgnlParser.andExpression(OgnlParser.java:352)
	at org.apache.ibatis.ognl.OgnlParser.exclusiveOrExpression(OgnlParser.java:299)
	at org.apache.ibatis.ognl.OgnlParser.inclusiveOrExpression(OgnlParser.java:246)
	at org.apache.ibatis.ognl.OgnlParser.logicalAndExpression(OgnlParser.java:193)
	at org.apache.ibatis.ognl.OgnlParser.logicalOrExpression(OgnlParser.java:140)
	at org.apache.ibatis.ognl.OgnlParser.conditionalTestExpression(OgnlParser.java:101)
	at org.apache.ibatis.ognl.OgnlParser.assignmentExpression(OgnlParser.java:64)
	at org.apache.ibatis.ognl.OgnlParser.expression(OgnlParser.java:23)
	at org.apache.ibatis.ognl.OgnlParser.topLevelExpression(OgnlParser.java:15)
	at org.apache.ibatis.ognl.Ognl.parseExpression(Ognl.java:110)
	... 40 more
mybatis <fireach> 拼接sql语句 org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.builder.BuilderException: Error evaluating expression 'in'. Cause:的更多相关文章
- Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ItemsCustom' in 'class com.pojo.OrderDetailCustom
		
再用 junit 测试MyBatis时发现的错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...
 - HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
		
HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.e ...
 - MyBatis-Exception:org.apache.ibatis.exceptions.PersistenceException
		
错误信息如下: HTTP Status 500 - org.mybatis.spring.MyBatisSystemException: nested exception is org.apache. ...
 - 详解Java的MyBatis框架中SQL语句映射部分的编写
		
这篇文章主要介绍了Java的MyBatis框架中SQL语句映射部分的编写,文中分为resultMap和增删查改实现两个部分来讲解,需要的朋友可以参考下 1.resultMap SQL 映射XML 文件 ...
 - Mybatis错误(一)org.apache.ibatis.exceptions.PersistenceException
		
在映射文件中,通过parameterType指定输入参数的类型,类型可以是简单类型.hashmap.pojo的包装类型.在测试包装类型过程中产生了一个错误:org.apache.ibatis.exce ...
 - org.apache.ibatis.exceptions.PersistenceException:  ### Error querying database.  Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manu
		
这个是sql 语句 错误 仔细检查 SQL语句是否写错了 org.apache.ibatis.exceptions.PersistenceException: ### Error queryi ...
 - MyBatis 构造动态 SQL 语句
		
以前看过一个本书叫<深入浅出 MFC >,台湾 C++ 大师写的一本书.在该书中写到这样一句话,“勿在浮沙筑高台”,这句话写的的确对啊.编程很多语言虽然相通,但是真正做还是需要认真的学习, ...
 - Error building SqlSession. ### The error may exist in dao/UserMapper.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration(2 字节的 UTF-8 序列的字节 2 无效。)
		
关于在学习Mybatis框架时运行报错 Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error building ...
 - StringBuilder 拼接sql语句比较快
		
StringBuilder 拼接sql语句比较快StringBuilder strBuilder = new StringBuilder();strSql += "insert into t ...
 
随机推荐
- 当Activity出现Exception时是如何处理的?
			
1.ActivityThread 2.PerformStop 在这里会调用mWindow.closeAllPanels(),从而关闭OptionMenu, ContextMenu.如果自己通过Wind ...
 - CSS垂直居中的四种方法
			
写在前面的话 最近在Stack Overflow上看到 一个不错的回答 ,以下是我对其的总结,分享给大家. 垂直居中的四种方法 ①基础的方法 设置父元素的line-height等于height,这种方 ...
 - IOS微信浏览器点击事件不起作用问题
			
问题: $(document).on("click",".btn",function(){alert("1")}); 在微信浏览器上点击不起 ...
 - r.js压缩打包
			
AMD模块化开发中的代码压缩打包工具——r.js 环境搭建基于nodejs:用于AMD模块化开发中的项目文件压缩打包,不是AMD模式也是可以的 javascript部分 压缩javascript项目开 ...
 - Eclipse One Inspector
			
net.sf.yari.eclipse.EclipseInspectorViewPart Through the outline of EclipseInspectorViewPart, we can ...
 - 16_AOP入门准备_Jdk动态代理模式
			
[工程截图] [PersonDao.java] package com.HigginCui.daoProxy; //目标类接口 public interface PersonDao { public ...
 - 在MVC中使用Bundle打包压缩js和css
			
第一步:安装 安装“System.Web.Optimization”:在中“NuGet”中搜索 安装. 第二步:配置 配置“Views”目录下的“web.config”文件增加“System.Web. ...
 - html 表格边框的设置
			
对于很多初学HTML的人来说,表格<table>是最常用的标签了,但对于表格边框的控制,很多初学者却不甚其解. 一般我们用表格的时候总会给它个border属性,比如:<table b ...
 - wxpython 创建工具栏和菜单栏
			
下面看一下关于创建工具栏,状态栏和菜单的方法,看下面一个例子: import wx class ToolBarFrame(wx.Frame): def __init__(self,parent,id) ...
 - maven学习(三)maven仓库
			
官网图片: maven仓库: 仓库通常配置在settings.xml文件中,此处注意settings.xml的优先级:用户 > 全局,广义上maven的仓库一共包含两种: 1.本地仓库,默认在& ...