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的更多相关文章

  1. 用mybatis将SQL查询语句”select * from user”的封装为配置文件

    用mybatis将SQL查询语句”select * from user”的封装为配置文件 定义一个xml映射文件,文件名见名知意.如user-mapper.xml,文件内容如下: <?xml v ...

  2. 【MyBatis源码分析】select源码分析及小结

    示例代码 之前的文章说过,对于MyBatis来说insert.update.delete是一组的,因为对于MyBatis来说它们都是update:select是一组的,因为对于MyBatis来说它就是 ...

  3. (十一)mybatis之映射器(select)

    映射器 映射器的主要元素有八种: 元素名称 描述 select 查询语句,可自定义参数 insert 插入语句,执行后返回插入的条数 update 更新语句,执行后返回更新的条数 delete 删除语 ...

  4. mybatis之@Select、@Insert、@Delete、@Param

    之前学习的时候,看到别人在使用mybatis时,用到@Select.@Insert.@Delete.@Param这几个注解,故楼主研究了一下,在这里与大家分享 当使用这几个注解的时候,可以省去写Map ...

  5. mybatis的嵌套查询(嵌套查询nested select和嵌套结果nested results查询)区别

    (转自:http://blog.csdn.net/canot/article/details/51485955) Mybatis表现关联关系比hibernate简单,没有分那么细致one-to-man ...

  6. mybatis 3.x源码深度解析与最佳实践(最完整原创)

    mybatis 3.x源码深度解析与最佳实践 1 环境准备 1.1 mybatis介绍以及框架源码的学习目标 1.2 本系列源码解析的方式 1.3 环境搭建 1.4 从Hello World开始 2 ...

  7. MyBatis1:MyBatis入门

    MyBatis是什么 MyBatis是什么,MyBatis的jar包中有它的官方文档,文档是这么描述MyBatis的: MyBatis is a first class persistence fra ...

  8. MyBatis架构(转)

    本文来自http://www.bubuko.com/infodetail-549184.html 如果不太熟悉MyBatis使用的请先参见MyBatis官方文档,这对理解其架构设计和源码分析有很大好处 ...

  9. MyBatis架构设计及源代码分析系列(一):MyBatis架构

    如果不太熟悉MyBatis使用的请先参见MyBatis官方文档,这对理解其架构设计和源码分析有很大好处. 一.概述 MyBatis并不是一个完整的ORM框架,其官方首页是这么介绍自己 The MyBa ...

随机推荐

  1. 【Android】Android 中string-array的用法

    在Android中,用string-array是一种简单的提取XML资源文件数据的方法. 例子如下: 把相应的数据放到values文件夹的arrays.xml文件里 <?xml version= ...

  2. Codeforces 887D Ratings and Reality Shows

    Ratings and Reality Shows 参加talk show的时间肯定是在某个t[ i ]的后一秒, 枚举一下就好了. #include<bits/stdc++.h> #de ...

  3. bug管理

    BUG提交规范 1.标题 2.步骤描述 ①.步骤使用序号编排 ②.在特定情况下发生的问题,还需提供准确的前提条件 ③.精准的描述bug产生的路径后,再描述现象 如: >打开客户端进行首页-> ...

  4. 51Nod1518 稳定多米诺覆盖 动态规划 插头dp 容斥原理

    原文链接https://www.cnblogs.com/zhouzhendong/p/51Nod1518.html 题目传送门 - 51Nod1518 题意 51Nod真是个好OJ ,题意概括的真好, ...

  5. BZOJ1799 self 同类分布 数位dp

    BZOJ1799self 同类分布 去博客园看该题解 题意 给出a,b,求出[a,b]中各位数字之和能整除原数的数的个数. [约束条件]1 ≤ a ≤ b ≤ 10^18 题解 1.所有的位数之和&l ...

  6. CSS选择器 + Xpath + 正则表达式整理(有空再整理)

    选择器 例子 例子描述 CSS .class .intro 选择 class="intro" 的所有元素. 1 #id #firstname 选择 id="firstna ...

  7. day 47 htm-part2

    列表 无序列表====所谓无序就是显示出来的效果没有编号排序 <ul type='disc'> <li>第一项</li> <li>第二项</li& ...

  8. StringBuffer 可变参数拼接

    @RequestMapping(value="/getFundsCount",method=RequestMethod.POST) public Result getFundsCo ...

  9. Mybatis if test 中int integer判断非空的坑

    Mybatis 中,alarmType 是int类型.如果alarmType 为0的话,条件判断返回结果为false,其它值的话,返回true. 1 <if test="alarmTy ...

  10. Typescript 常见的几种函数重载方法详解与应用示例

    所谓的重载,其实就是使用相同的函数名,传入不同数量的参数或不同类型的参数,以此创建出多个方法或产生不同结果. 1. 最常见的,也就是根据定义傻瓜式地判断参数类型与数量 function showPer ...