ibatis 使用遇到的问题1
来源:互联网 发布:免费舆情分析软件 编辑:程序博客网 时间:2024/06/06 02:44
<sql id="whereStatement">
<dynamic prepend="where">
is_deleted=0
<isNotEmpty prepend="and" property="id"
removeFirstPrepend="true">id=#id#</isNotEmpty>
<isNotEmpty prepend="and" property="searchWord"
removeFirstPrepend="true">search_word like concat('%',#searchWord#,'%')</isNotEmpty>
<isNotEmpty prepend="and" property="showWord"
removeFirstPrepend="true">show_word like concat('%',#showWord#,'%')</isNotEmpty>
<isNotEmpty prepend="and" property="state"
removeFirstPrepend="true">state=#state#</isNotEmpty>
<isNotEmpty prepend="and" property="entryType"
removeFirstPrepend="true">entry_type=#entryType#</isNotEmpty>
<isNotEmpty prepend="and" property="startTime"
removeFirstPrepend="true"><![CDATA[ gmt_end >= #startTime# ]]></isNotEmpty>
<isNotEmpty prepend="and" property="endTime"
removeFirstPrepend="true"><![CDATA[ gmt_start <= #endTime# ]]></isNotEmpty>
</dynamic>
</sql>
ibatis的xml中,
<dynamic> </dynamic>里面千万不能有 is_deleted=0 这种固定的条件,不然会报如下错误:
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'state = 0 and entry_type = 1 and location = 1 and gmt_end >= '2017-04-2' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
研究了好久。。。
还有,ibatis中的sql文件中,一定能加 “ ”空格的地方一定加上,不然不知道什么时候就会因为一个空格报错 找不到原因
- ibatis 使用遇到的问题1
- 使用Ibatis一路中遇到的问题
- Ibatis使用过程中遇到的问题。
- ibatis使用遇到问题总结
- 关于ibatis使用中遇到的问题 和解决方案
- ibatis 遇到的问题及解决方法
- spring整合ibatis中遇到的问题
- 今天遇到一个问题,关于ibatis的
- 本人初次使用Ibatis操作MS SqlServer2000数据库遇到的问题
- ibatis中写SQL语句时使用in遇到的问题描述
- ibatis resultMap使用的问题
- iBatiS中遇到的sql上的问题小结
- 初学ibatis,总结遇到的问题(一)
- 解决 遇到的 ibatis连接oracle 乱码问题
- ibatis查询出结果持久化时遇到的问题
- IBatis.Net 学习中遇到的问题及解决办法
- 使用cognos8.4遇到的问题1
- 使用win8.1遇到的一些问题
- SVM三重境界
- 水仙花数(难度系数:半颗星)
- LeetCode#86. Partition List
- acm_整数求和
- Mybatis连接数据库时报错原因归纳
- ibatis 使用遇到的问题1
- Caffe学习笔记(四):使用pycaffe生成train.prototxt、test.prototxt文件
- Linux中的MySQL
- MySQL命令大全
- Java并发编程:volatile关键字解析
- java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 21
- 机器学习中的局部加权线性回归
- android 沉浸式状态栏
- 运算符