码迷,mamicode.com
首页 > 其他好文 > 详细

Mybatis : "less than" issue in Select annotations

时间:2017-10-20 16:51:32      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:sel   exception   googl   cti   ges   amp   ase   str   ini   

I am using java7, spring 3 and mybatis

Pom.xml

<org.mybatis-version>3.2.8</org.mybatis-version>
<org.mybatis-spring-version>1.2.2</org.mybatis-spring-version>

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>${org.mybatis-version}</version>
</dependency>
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>${org.mybatis-spring-version}</version>
</dependency>

While using annotation based Select i came across with strange issue where below mentioned code was throwing exception due to use of < (Less then) while > (greater then) works as expected.

<script>
SELECT * FROM STUDENT
WHERE DEPARTMENT_ID = #{depId}
<if test=‘joiningDate != null‘> AND STUDENT_ID <= #{joiningDate} </if>
</script>

After googling for a while i find out this issue reported below.

https://code.google.com/p/mybatis/issues/detail?id=787

Above issue can be fixed by replacing < (less then) with &lt; as shown below.

<script>
SELECT * FROM STUDENT
WHERE DEPARTMENT_ID = #{depId}
<if test=‘joiningDate != null‘> AND STUDENT_ID &lt;= #{joiningDate} </if>
</script>

I have also came across of suggestion for using using CDATA or ^ in respected scenarios which i haven‘t given try yet.

 

转自:http://www.itkeyword.com/doc/6200397421789202130/mybatis-less-than-issue-in-select-annotations

Mybatis : "less than" issue in Select annotations

标签:sel   exception   googl   cti   ges   amp   ase   str   ini   

原文地址:http://www.cnblogs.com/zjoch/p/7700026.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!