
MyBatis
袭冷
梦里不知身是客
展开
-
Mybatis - 在If标签中非空判断数字0时不正确的问题
一、问题 1、通常在对一个字段做非空判断时采取的方式如下,执行结果是符合预期的<if test="name != null and name != ''"> AND name = #{name}</if> 2、但是当这个字段的类型为数字且值为0时,会发现语句没有连接,判断失败<if test="status != null ...原创 2020-01-10 14:15:34 · 1634 阅读 · 1 评论 -
MyBatis - 使用foreach迭代List/Array的说明
在 MyBatis 中的 foreach 元素,主要用于迭代 集合数据 以动态生成执行语句;主要有 item、index、collection、open、separator、close 等属性属性说明 collection:要迭代的数据集对象,必填项 item:迭代出的元素的别名,必填项 index:元素的序号(map时为k...原创 2020-01-10 14:15:52 · 1943 阅读 · 0 评论 -
MyBatis - 单参数的传递方式
本章只对 Dao 接口声明中,入参为单个参数 且 类型为基础类型(Integer、Long、String 等)做说明,对于复杂类型( Bean、Map 等)和多参数类型 统一到多参数章节说明 在 Mapper 的 XML 文件中,入参声明的 parameterType 属性,是可选的参数,可以不指定 内置参数 _parameter 代表的是 Dao 接口中声明的所有参数...原创 2020-01-10 14:16:01 · 1546 阅读 · 0 评论 -
MyBatis - 多参数的传递方式
此章对 Dao 接口中 多个基础类型参数、或单参数但为 Bean / Map 等复杂类型、或者多个复杂类型参数 的情况_parameter 当 Dao 接口中定义的是一个复杂类型参数时,此时内置参数_parameter 代表的是当前参数对应的复杂类型对象 当 Dao 接口中定义的是多个参数时,多个参数会被封装为一个 map 类型,此时内置参数_parameter ...原创 2020-01-10 14:15:56 · 359 阅读 · 0 评论 -
MyBatis - 在Xml中实现模糊查询
一、文本替换模式(有SQL注入风险)<if test="title != null and title != ''"> AND title like '%${title}%'</if>二、使用 Bind 标签<if test="title != null and title != ''"> <bind name="titleLike...原创 2019-11-08 11:13:20 · 1747 阅读 · 0 评论 -
MyBatis - 在Xml的SQL语句中添加注释
<!-- SQL外的注释:使用XML的标准注释 --> <select id="selectUser" resultType="com.xl.entity.UserEntity"> SELECT /* SQL中的注释:采用SQL多行注释 */ id, name, status FROM users ORDER BY id ...原创 2019-11-08 11:13:50 · 5327 阅读 · 2 评论 -
MyBatis - java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符
一、异常org.springframework.jdbc.BadSqlGrammarException: Error updating database. Caused by: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符 at oracle.jdbc.driver.SQLStateMapping.newSQLE...原创 2018-08-08 21:36:33 · 2757 阅读 · 0 评论 -
MyBatis - java.sql.SQLException: 无效的列类型: 1111
异常org.springframework.jdbc.UncategorizedSQLException: Error setting null parameter. Most JDBC drivers require that the JdbcType must be specified for all nullable parameters. Caused b...原创 2018-08-08 21:36:47 · 3208 阅读 · 0 评论