Mybatis : "less than" issue in Select annotations
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 < as shown below.
<script>
SELECT * FROM STUDENT
WHERE DEPARTMENT_ID = #{depId}
<if test='joiningDate != null'> AND STUDENT_ID <= #{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的更多相关文章
- 用mybatis将SQL查询语句”select * from user”的封装为配置文件
用mybatis将SQL查询语句”select * from user”的封装为配置文件 定义一个xml映射文件,文件名见名知意.如user-mapper.xml,文件内容如下: <?xml v ...
- 【MyBatis源码分析】select源码分析及小结
示例代码 之前的文章说过,对于MyBatis来说insert.update.delete是一组的,因为对于MyBatis来说它们都是update:select是一组的,因为对于MyBatis来说它就是 ...
- (十一)mybatis之映射器(select)
映射器 映射器的主要元素有八种: 元素名称 描述 select 查询语句,可自定义参数 insert 插入语句,执行后返回插入的条数 update 更新语句,执行后返回更新的条数 delete 删除语 ...
- mybatis之@Select、@Insert、@Delete、@Param
之前学习的时候,看到别人在使用mybatis时,用到@Select.@Insert.@Delete.@Param这几个注解,故楼主研究了一下,在这里与大家分享 当使用这几个注解的时候,可以省去写Map ...
- mybatis的嵌套查询(嵌套查询nested select和嵌套结果nested results查询)区别
(转自:http://blog.csdn.net/canot/article/details/51485955) Mybatis表现关联关系比hibernate简单,没有分那么细致one-to-man ...
- mybatis 3.x源码深度解析与最佳实践(最完整原创)
mybatis 3.x源码深度解析与最佳实践 1 环境准备 1.1 mybatis介绍以及框架源码的学习目标 1.2 本系列源码解析的方式 1.3 环境搭建 1.4 从Hello World开始 2 ...
- MyBatis1:MyBatis入门
MyBatis是什么 MyBatis是什么,MyBatis的jar包中有它的官方文档,文档是这么描述MyBatis的: MyBatis is a first class persistence fra ...
- MyBatis架构(转)
本文来自http://www.bubuko.com/infodetail-549184.html 如果不太熟悉MyBatis使用的请先参见MyBatis官方文档,这对理解其架构设计和源码分析有很大好处 ...
- MyBatis架构设计及源代码分析系列(一):MyBatis架构
如果不太熟悉MyBatis使用的请先参见MyBatis官方文档,这对理解其架构设计和源码分析有很大好处. 一.概述 MyBatis并不是一个完整的ORM框架,其官方首页是这么介绍自己 The MyBa ...
随机推荐
- C# 之 向服务器上传资源
首先写客服端,winform 应用 或者 WPF 应用 模拟一个post提交: /// <summary> /// 将本地文件上传到指定的服务器(HttpWebRequest方法) /// ...
- json 解析代码 全语言
Javascript: 1.使用eval var parse_json_by_eval = function(str){ return eval('('+str+')'); } var value = ...
- 安全测试robots
http://stock.pingan.com/robots.txt
- 浏览器iscroll
::-webkit-scrollbar{width:4px;height:4px;background:transparent}::-webkit-scrollbar-track{background ...
- 使用VMware通过vmdk文件创建XP虚拟机
一.打开VMware workstation10,转到主页,选择“创建新的虚拟机”,然后选择“自定义(高级)”选项 二.虚拟机硬件兼容性选择默认兼容10.0模式,下一步之后,选择“稍后安装操作系统” ...
- C/C++中如何获取数组的长度(宏&模板)
C.C++中没有提供 直接获取数组长度的函数.对于存放字符串的字符数组提供了一个strlen函数获取长度,那么对于其他类型的数组如何获取他们的长度呢?其中一种方法是使 用 sizeof(array) ...
- day64 django django零碎知识点整理
本文转载自紫金葫芦,哪吒,liwenzhou.cnblog博客地址 简单了解mvc框架和MTV框架, mvc是一种简单的软件架构模式: m----model,模型 v---view,视图 c---co ...
- 使用entitiy
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...
- Nowcoder contest 392 I 逛公园 (无向图割边模板)
<题目链接> 题目描述: 月月和华华一起去逛公园了.公园很大,为了方便,可以抽象的看成一个N个点M条边的无向连通图(点是景点,边是道路).公园唯一的入口在1号点,月月和华华要从这里出发,并 ...
- POJ 2112 Optimal Milking (二分+最短路+最大流)
<题目链接> 题目大意: 有K台挤奶机和C头奶牛,都被视为物体,这K+C个物体之间存在路径.给出一个 (K+C)x(K+C) 的矩阵A,A[i][j]表示物体i和物体j之间的距离,有些物体 ...