当前使用版本(必填,否则不予处理)

当前版本3.3.1

该问题是如何引起的?(确定最新版也有问题再提!!!)

在使用mapper.xml sql 进行指定多列的IN子查询 Mybatis是支持的但是Plus 中就会在解析器这一步 报错

用法:

重现步骤(如果有就写完整)

Java Mapper 接口 List<InvNoticeWoColVO> getInvoiceWoColByOrderIdAndLineId(@Param("list") List<Map<String, Object>> paramMaps,@Param("noticeId") Integer noticeId);

XML mapper文件

<select id="getInvoiceWoColByOrderIdAndLineId" resultType="com.chinaztt.ztt.order.vo.InvNoticeWoColVO" parameterType="java.util.List">

       select notice.status,col.* from inv_notice_wo_col col
        left join inv_notice notice on col.inv_notice_id =notice.id
        where col.del_flag=0
        <if test="noticeId !=null and noticeId !=''">
            and col.inv_notice_id = #{noticeId}
        </if>
        and (col.order_id,col.order_line_id) in
        <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
            (#{item.orderId},#{item.orderLineId})
        </foreach>
    </select>

报错信息

Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, please exclude the tableName or statementId.

Error SQL: select notice.status,col.* from inv_notice_wo_col col left join inv_notice notice on col.inv_notice_id =notice.id where col.del_flag=0

    and (col.order_id,col.order_line_id) in
     (  
        (?,?)
     )

The error may exist in file [D:\project\otc-order\otc-order-biz\target\classes\mapper\InvNoticeMapper.xml]

The error may involve com.chinaztt.ztt.order.mapper.InvNoticeMapper.getInvoiceWoColByOrderIdAndLineId

The error occurred while executing a query

Cause: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, please exclude the tableName or statementId.

Error SQL: select notice.status,col.* from inv_notice_wo_col col left join inv_notice notice on col.inv_notice_id =notice.id where col.del_flag=0

    and (col.order_id,col.order_line_id) in
     (  
        (?,?)
     )
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:149)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140)
at sun.reflect.GeneratedMethodAccessor447.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:426)
... 122 more

Caused by: com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Failed to process, please exclude the tableName or statementId. Error SQL: select notice.status,col.* from inv_notice_wo_col col left join inv_notice notice on col.inv_notice_id =notice.id where col.del_flag=0

    and (col.order_id,col.order_line_id) in
     (  
        (?,?)
     )
at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:39)
at com.baomidou.mybatisplus.core.parser.AbstractJsqlParser.parser(AbstractJsqlParser.java:74)
at com.baomidou.mybatisplus.extension.handlers.AbstractSqlParserHandler.sqlParser(AbstractSqlParserHandler.java:76)
at com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor.intercept(PaginationInterceptor.java:175)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy321.prepare(Unknown Source)
at sun.reflect.GeneratedMethodAccessor433.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)
at com.chinaztt.ztt.common.data.datascope.DataScopeInterceptor.intercept(DataScopeInterceptor.java:72)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:61)
at com.sun.proxy.$Proxy321.prepare(Unknown Source)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.prepareStatement(MybatisSimpleExecutor.java:92)
at com.baomidou.mybatisplus.core.executor.MybatisSimpleExecutor.doQuery(MybatisSimpleExecutor.java:66)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:163)
at com.baomidou.mybatisplus.core.executor.MybatisCachingExecutor.query(MybatisCachingExecutor.java:90)
at sun.reflect.GeneratedMethodAccessor444.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)
at com.sun.proxy.$Proxy320.query(Unknown Source)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)
... 127 more

Caused by: net.sf.jsqlparser.JSQLParserException at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatements(CCJSqlParserUtil.java:137) at com.baomidou.mybatisplus.core.parser.AbstractJsqlParser.parser(AbstractJsqlParser.java:60) ... 150 more Caused by: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "," "," at line 5, column 20.

Was expecting one of:

"&"
"&&"
")"
"::"
"<<"
">>"
"AND"
"COLLATE"
"["
"^"
"|"

Comment From: miemieYaho

jsqlparser 不支持解析

Comment From: qmdx

修改为如下试试

<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
 #{item.orderId},#{item.orderLineId}
</foreach>

Comment From: qmdx

up 有更多问题打开反馈