java mybatis 动态sql
//-------------------------------查询-------------------------------------//
<sql id="cmsGuestbookColumns">
a.id AS "id",
a.GROUP_NUMBER AS "groupNumber",
a.GROUP_NAME AS "groupName",
a.GROUP_AMOUNT as "groupAmount",
a.GROUP_STATUS AS "groupStatus",
a.RULES AS "rules",
a.DELETE_STATUS AS "deleteStatus",
<!-- a.MODIFIEDBY AS "modifiedby", -->
a.MODIFIEDBY AS "updateBy",
<!-- DATE_FORMAT(a.MODIFIEDON,'%Y-%m-%d %H:%i:%s') AS "modifiedon", -->
DATE_FORMAT(a.MODIFIEDON,'%Y-%m-%d %H:%i:%s') AS "updateDate",
a.CREATEDBY AS "createdby",
<!-- DATE_FORMAT(a.CREATEDON,'%Y-%m-%d %H:%i:%s') AS "createdon" -->
DATE_FORMAT(a.CREATEDON,'%Y-%m-%d %H:%i:%s') AS "createDate"
</sql>
<select id="findList" resultType="com.thinkgem.jeesite.modules.rule.entity.RuleCombinationModel">
SELECT
<include refid="cmsGuestbookColumns"/>
FROM t_zg_rule_group a
<where>
a.DELETE_STATUS = 0
<if test="groupNumber!='' and groupNumber!=null ">
and a.GROUP_NUMBER=#{groupNumber}
</if>
<if test="groupName!='' and groupName!=null ">
and a.GROUP_NAME=#{groupName}
</if>
<if test="groupStatus!='' and groupStatus!=null ">
and a.GROUP_STATUS=#{groupStatus}
</if>
</where>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY a.CREATEDON DESC
</otherwise>
</choose>
</select>
//-------------------------------修改-------------------------------------//
<update id="update">
UPDATE t_zg_rule_group
<set>
<if test="groupNumber !='' and groupNumber !=null">
GROUP_NUMBER=#{groupNumber},
</if>
<if test="groupName !='' and groupName !=null">
GROUP_NAME=#{groupName},
</if>
<if test="groupStatus !='' and groupStatus !=null">
GROUP_STATUS=#{groupStatus},
</if>
<if test="groupAmount !='' and groupAmount !=null">
GROUP_AMOUNT=#{groupAmount},
</if>
<if test="deleteStatus !='' and deleteStatus !=null">
DELETE_STATUS=#{deleteStatus},
</if>
<if test="modifiedby !='' and modifiedby !=null">
MODIFIEDBY=#{modifiedby},
</if>
</set>
WHERE id = #{id}
</update>
java mybatis 动态sql的更多相关文章
- Java EE数据持久化框架 • 【第4章 MyBatis动态SQL】
全部章节 >>>> 本章目录 4.1 MyBatis动态标签 4.1.1 MyBatis动态标签介绍 4.1.2 < if >标签 4.1.3 update语 ...
- mybatis实战教程(mybatis in action)之八:mybatis 动态sql语句
mybatis 的动态sql语句是基于OGNL表达式的.可以方便的在 sql 语句中实现某些逻辑. 总体说来mybatis 动态SQL 语句主要有以下几类:1. if 语句 (简单的条件判断)2. c ...
- 9.mybatis动态SQL标签的用法
mybatis动态SQL标签的用法 动态 SQL MyBatis 的强大特性之一便是它的动态 SQL.如果你有使用 JDBC 或其他类似框架的经验,你就能体会到根据不同条件拼接 SQL 语句有多么 ...
- 自己动手实现mybatis动态sql
发现要坚持写博客真的是一件很困难的事情,各种原因都会导致顾不上博客.本来打算写自己动手实现orm,看看时间,还是先实现一个动态sql,下次有时间再补上orm完整的实现吧. 用过mybatis的人,估计 ...
- Mybatis动态SQL单一基础类型参数用if标签
Mybatis动态SQL单一基础类型参数用if标签时,test中应该用 _parameter,如: 1 2 3 4 5 6 <select id="selectByName" ...
- Mybatis动态SQL简单了解 Mybatis简介(四)
动态SQL概况 MyBatis 的强大特性之一便是它的动态 SQL 在Java开发中经常遇到条件判断,比如: if(x>0){ //执行一些逻辑........ } Mybatis应用中,S ...
- mybatis原理分析学习记录,mybatis动态sql学习记录
以下个人学习笔记,仅供参考,欢迎指正. MyBatis 是支持定制化 SQL.存储过程以及高级映射的持久层框架,其主要就完成2件事情: 封装JDBC操作 利用反射打通Java类与SQL语句之间的相互转 ...
- mybatis 动态sql和参数
mybatis 动态sql 名词解析 OGNL表达式 OGNL,全称为Object-Graph Navigation Language,它是一个功能强大的表达式语言,用来获取和设置Java对象的属性, ...
- MyBatis动态SQL(认真看看, 以后写SQL就爽多了)
目录 0 一起来学习 mybatis 1 数据准备 2 if 标签 2.1 在 WHERE 条件中使用 if 标签 2.1.1 查询条件 2.1.2 动态 SQL 2.1.3 测试 2.2 在 UPD ...
随机推荐
- FileUpload文件上传控件
1.FileUpload控件的主要功能是向指定目录上传文件.FileUpload控件不会自动上传控件,而需要设置相关的事件处理程序,然后在程序中实现文件上传. 2.FileUpload控件常见的属性 ...
- 在Windows7下启动MongoDB服务的解决方案
1:首先去官网下载程序,我用的是1.4.3版本,地址: http://downloads.mongodb.org/win32/mongodb-win32-i386-1.4.3.zip 2:创建一个DB ...
- Spark Kill Application
yarn application -kill <applicationId>
- SVN :This XML file does not appear to have any style information associated with it.
SVN :This XML file does not appear to have any style information associated with it. The document tr ...
- java.io包中的字节流—— FilterInputStream和FilterOutputStream
接着上篇文章,本篇继续说java.io包中的字节流.按照前篇文章所说,java.io包中的字节流中的类关系有用到GoF<设计模式>中的装饰者模式,而这正体现在FilterInputStre ...
- php一些特殊函数的使用实例详解
<?php /* * PHP Array 函数大全 * * array() 创建数组. 3 array_change_key_case() 返回其键均为大写或小写的数组. 4 array_chu ...
- Python强化训练笔记(三)——词频的统计
现有列表如下: [6, 7, 5, 9, 4, 1, 8, 6, 2, 9] 希望统计各个元素出现的次数,可以看作一个词频统计的问题. 我们希望最终得到一个这样的结果:{6:2, 7:1...}即 { ...
- FastDFS connect timed out
java.net.SocketTimeoutException: connect timed outUpload file "1003.png"fails:connect time ...
- Run P4 without P4factory - A Simple Example In Tutorials. -2 附 simple_router源码
/* Copyright 2013-present Barefoot Networks, Inc. Licensed under the Apache License, Version 2.0 (th ...
- JSTL标签出错:<c:forEach var="book" items="${requestScope.books}" varStatus="status">
今天在运行书里的JSTL标签代码的时候出错,总结一下: 问题1.The JSP specification requires that an attribute name is preceded by ...