mybatis在工作中的使用简介
来源:互联网 发布:淘宝假发 编辑:程序博客网 时间:2024/05/18 16:35
<?xml version="1.0" encoding= "UTF-8"?><!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" ><mapper namespace="tbl_xxxx"> <select id="selectAllDicts" parameterType="com.form.nokia.tbl_xxxx" resultType="com.form.nokia.tbl_xxxx"> select * from tbl_xxxx t <where> <if test="key_seq != null and key_seq !='' "> t.key_seq = #{key_seq} </if> <if test="key_type != null and key_type !='' "> and t.key_type=#{key_type} </if> <if test="key_index != null and key_index !='' "> AND t.key_index =#{key_index} </if> </where> </select><!--根据指定的条件查询总数--> <select id="selectCount" parameterType="com.form.nokia.tbl_xxxx" resultType="java.lang.Integer"> select count(1) from tbl_xxxx t <where> <if test="key_seq != null and key_seq !='' "> t.key_seq = #{key_seq} </if> <if test="key_type != null and key_type !='' "> and t.key_type=#{key_type} </if> <if test="key_index != null and key_index !='' "> AND t.key_index =#{key_index} </if> </where> </select> <select id="select" parameterType="com.form.nokia.tbl_xxxx" resultType="com.form.nokia.tbl_xxxx"> <![CDATA[ SELECT tt.*, d.dictvaluedesc as key_typedesc FROM ( ]]> SELECT * FROM (SELECT a.*,ROWNUM AS rn FROM ( select t.* from tbl_xxxx t <where> <if test="key_seq != null and key_seq !='' "> t.key_seq = #{key_seq} </if> <if test="key_type != null and key_type !='' "> and t.key_type=#{key_type} </if> <if test="key_index != null and key_index !='' "> AND t.key_index =#{key_index} </if> </where> <if test="sortString != null"> order by ${sortString} </if> ) a WHERE #{to} >=ROWNUM) b WHERE b.rn >= #{from} ) tt left join dictinfotb d on tt.key_type=d.dictvalue and d.dicttype=20018 and d.locale='zh_CN' <if test="sortString != null"> order by ${sortString} </if> </select> <!--添加一条记录--> <insert id="insert" parameterType="com.form.nokia.tbl_xxxx"> insert into tbl_xxxx <trim prefix="(" suffixOverrides=","> <if test="key_seq != null">key_seq ,</if> <if test="key_type != null">key_type ,</if> <if test="key_usage != null">key_usage ,</if> <if test="save_idex != null">save_idex ,</if> <if test="key_index != null">key_index ,</if> <if test="key_value != null">key_value ,</if> <if test="pri_key != null">pri_key ,</if> <if test="rsa_exp != null">rsa_exp ,</if> <if test="key_chk != null">key_chk ,</if> <if test="create_uid != null">create_uid ,</if> <if test="create_time != null">create_time ,</if> <if test="last_modify_uid != null">last_modify_uid ,</if> <if test="last_modify_time != null">last_modify_time ,</if> </trim> ) values <trim prefix="(" suffixOverrides=","> <if test="key_seq != null">#{key_seq },</if> <if test="key_type != null">#{key_type },</if> <if test="key_usage != null">#{key_usage },</if> <if test="save_idex != null">#{save_idex },</if> <if test="key_index != null">#{key_index },</if> <if test="key_value != null">#{key_value },</if> <if test="pri_key != null">#{pri_key },</if> <if test="rsa_exp != null">#{rsa_exp },</if> <if test="key_chk != null">#{key_chk },</if> <if test="create_uid != null">#{create_uid },</if> <if test="create_time != null">#{create_time },</if> <if test="last_modify_uid != null">#{last_modify_uid },</if> <if test="last_modify_time != null">#{last_modify_time },</if> </trim> ) </insert> <!--更新一条记录--> <update id="update" parameterType="com.form.nokia.tbl_xxxx"> update tbl_xxxx <set> <if test="key_seq != null">key_seq =#{key_seq },</if> <if test="key_type != null">key_type =#{key_type },</if> <if test="key_usage != null">key_usage =#{key_usage },</if> <if test="save_idex != null">save_idex =#{save_idex },</if> <if test="key_index != null">key_index =#{key_index },</if> <if test="key_value != null">key_value =#{key_value },</if> <if test="pri_key != null">pri_key =#{pri_key },</if> <if test="rsa_exp != null">rsa_exp =#{rsa_exp },</if> <if test="key_chk != null">key_chk =#{key_chk },</if> <if test="create_uid != null">create_uid =#{create_uid },</if> <if test="create_time != null">create_time =#{create_time },</if> <if test="last_modify_uid != null">last_modify_uid =#{last_modify_uid },</if> <if test="last_modify_time != null">last_modify_time =#{last_modify_time},</if> </set> where key_seq=#{key_seq} </update> <!--删除一条记录--> <delete id="delete" parameterType="com.form.nokia.tbl_xxxx"> delete from tbl_xxxx where key_seq=#{key_seq} and key_type=#{key_type} </delete></mapper>
1.以上是mybatis的增删改查:工作中常用到的。
0 0
- mybatis在工作中的使用简介
- myeclipse在工作中的使用
- JS单例模式在工作中的使用
- mysql临时表在工作中的使用
- 在工作中常使用Js的技巧
- 【MyBatis】第一章:MyBatis的简介和入门使用
- 在工作中使用block遇到一些问题和新的认识
- 98% 的开发者在工作中使用了开源软件
- 关于在工作中使用dubbo和zookeeper的一些理解
- mybatis简介及使用
- MyBatis使用简介
- 在工作中的一点体会
- 在工作中碰到的问题
- 在工作中的一点点体会
- Python在工作中的应用
- gulp在工作中的应用
- MyBatis 的 resultMap 简介
- MyBatis 的 resultMap 简介
- 软件测试实践-性能测试
- 4种系统间交互方法比较
- awk匹配操作符
- HttpClient 模拟登录手机版新浪微博
- 敏捷软件开发之环境准备
- mybatis在工作中的使用简介
- 第三章
- 第三章作业
- 关于Android Repo
- Java线程面试题 Top 50
- Effective Java Item9-在覆盖equals方法的同时覆盖hashCode
- 内核编译错误:crypto/signature/ksign-publickey.c:2:17: error: key.h: No such file or directory
- 携程首页 view按下缩进
- Cocos2d-x坐标系