this is very strange,
Comment From: harawata
Hello @AnswerNo2 ,
Please create a small demo project like these and share it on GitHub. We need to reproduce the problem to investigate.
p.s. Please use text instead of images. Code/messages in an image cannot be copied nor searched.
Comment From: AnswerNo2
the github address is https://github.com/AnswerNo2/spring-mybatis-question-demo
------------------ 原始邮件 ------------------ 发件人: "mybatis/mybatis-3" <notifications@github.com>; 发送时间: 2020年8月22日(星期六) 凌晨0:03 收件人: "mybatis/mybatis-3"<mybatis-3@noreply.github.com>; 抄送: "司空摘星"<784886724@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [mybatis/mybatis-3] when i use mybatis foreach tag, and i get some wrong, what reason? (#2019)
Hello @AnswerNo2 ,
Please create a small demo project like these and share it on GitHub. We need to reproduce the problem to investigate.
p.s. Please use text instead of images. Code/messages in an image cannot be copied nor searched.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
Comment From: harawata
Thank you for the project, @AnswerNo2 ,
It seems to be the pagehelper that generates the order by []
.
Even if I removed the <if />
element, the executed SQL still contains the same order by []
.
--- a/src/main/resources/mapper/PersonMapper.xml
+++ b/src/main/resources/mapper/PersonMapper.xml
@@ -17,9 +17,6 @@
</sql>
<select id="testName" parameterType="map" resultMap="userInfoMap">
select * from person where name = #{name}
- <if test="orderBy != null and orderBy.size()!=0">
- order by<foreach collection="orderBy" item="item" separator=",">${item}</foreach>
- </if>
</select>
<select id="test" resultMap="userInfoMap">
And if I removed the pagehelper dependency from the pom.xml, the order by []
is not added anymore.
--- a/pom.xml
+++ b/pom.xml
@@ -27,11 +27,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
- <dependency>
- <groupId>com.github.pagehelper</groupId>
- <artifactId>pagehelper-spring-boot-starter</artifactId>
- <version>1.2.3</version>
- </dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
As pagehelper is not our product, please ask for a help on their tracker. https://github.com/pagehelper/Mybatis-PageHelper
Comment From: AnswerNo2
oh, I forget pagehelper's jar, thank you for your answer,very much , and my doubts have been solved ,thank you ! appreciate you
------------------ 原始邮件 ------------------ 发件人: "Iwao AVE!"<notifications@github.com>; 发送时间: 2020年8月23日(星期天) 下午3:35 收件人: "mybatis/mybatis-3"<mybatis-3@noreply.github.com>; 抄送: "司空摘星"<784886724@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [mybatis/mybatis-3] when i use mybatis foreach tag, and i get some wrong, what reason? (#2019)
Thank you for the project, @AnswerNo2 ,
It seems to be the pagehelper that generates the order by [].
Even if I removed the <if /> element, the executed SQL still contains the same order by []. --- a/src/main/resources/mapper/PersonMapper.xml +++ b/src/main/resources/mapper/PersonMapper.xml @@ -17,9 +17,6 @@ </sql> <select id="testName" parameterType="map" resultMap="userInfoMap"> select * from person where name = #{name} - <if test="orderBy != null and orderBy.size()!=0"> - order by<foreach collection="orderBy" item="item" separator=",">${item}</foreach> - </if> </select> <select id="test" resultMap="userInfoMap">
And if I removed the pagehelper dependency from the pom.xml, the order by [] is not added anymore. --- a/pom.xml +++ b/pom.xml @@ -27,11 +27,6 @@ <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> - <dependency> - <groupId>com.github.pagehelper</groupId> - <artifactId>pagehelper-spring-boot-starter</artifactId> - <version>1.2.3</version> - </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId>
As pagehelper is not our product, please ask for a help on their tracker. https://github.com/pagehelper/Mybatis-PageHelper
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.