XML的mybatis
来源:互联网 发布:非农数据在哪里看 编辑:程序博客网 时间:2024/04/28 20:47
<?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="命名空间">
<!-- 根据ID得到一条记录 -->
<select id="toGet" parameterType="ActionValues" resultType="ResultValues">
select * from 表名 where upper(id)=upper(#{id})
</select>
<!--综合查询-->
<select id="toQuery" parameterType="ActionValues" resultType="ResultValues">
select id,name,sex,mobile,address from 表名
<trim prefix="where" prefixOverrides="and|or">
<if test="null!=id">upper(id) like upper('%${id}%')</if>
<if test="null!=name"> and upper(name) like upper('%${name}%') </if>
<if test="null!=sex"> and upper(sex) like upper('%${sex}%') </if>
<if test="null!=mobile"> and upper(mobile) like upper('%${mobile}%') </if>
<if test="null!=address"> and upper(address) like upper('%${address}%') </if>
</trim>
</select>
insert into 表名(
<if test="null!=id">id</if>
<if test="null!=name">,name</if>
<if test="null!=sex">,sex</if>
<if test="null!=mobile">,mobile</if>
<if test="null!=address">,address</if>
)values(
<if test="null!=id">upper(#{id,jdbcType=VARCHAR})</if>
<if test="null!=name">,upper(#{name,jdbcType=VARCHAR})</if>
<if test="null!=sex">,upper(#{sex,jdbcType=VARCHAR})</if>
<if test="null!=mobile">,upper(#{mobile,jdbcType=VARCHAR})</if>
<if test="null!=address">,upper(#{address,jdbcType=VARCHAR})</if>
)
</insert>
<if test="null!=id">
update 表明
<trim prefix="SET" suffixOverrides=",">
<if test="null != id">upper(id=#{id})</if>
<if test="null != name">,upper(name=#{name})</if>
<if test="null != sex">,upper(sex=#{sex})</if>
<if test="null != mobile">,upper(mobile=#{mobile})</if>
<if test="null != address">,upper(address=#{address})</if>
</trim>
where upper(id)=upper(#{id})
</if>
</update>
<if test="null!=id">
delete from 表名 where upper(id)=upper(#{id})
</if>
</delete>
</mapper>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="命名空间">
<!-- 根据ID得到一条记录 -->
<select id="toGet" parameterType="ActionValues" resultType="ResultValues">
select * from 表名 where upper(id)=upper(#{id})
</select>
<!--综合查询-->
<select id="toQuery" parameterType="ActionValues" resultType="ResultValues">
select id,name,sex,mobile,address from 表名
<trim prefix="where" prefixOverrides="and|or">
<if test="null!=id">upper(id) like upper('%${id}%')</if>
<if test="null!=name"> and upper(name) like upper('%${name}%') </if>
<if test="null!=sex"> and upper(sex) like upper('%${sex}%') </if>
<if test="null!=mobile"> and upper(mobile) like upper('%${mobile}%') </if>
<if test="null!=address"> and upper(address) like upper('%${address}%') </if>
</trim>
</select>
<!--新增-->
<insert id="toInsert" parameterType="ActionValues">insert into 表名(
<if test="null!=id">id</if>
<if test="null!=name">,name</if>
<if test="null!=sex">,sex</if>
<if test="null!=mobile">,mobile</if>
<if test="null!=address">,address</if>
)values(
<if test="null!=id">upper(#{id,jdbcType=VARCHAR})</if>
<if test="null!=name">,upper(#{name,jdbcType=VARCHAR})</if>
<if test="null!=sex">,upper(#{sex,jdbcType=VARCHAR})</if>
<if test="null!=mobile">,upper(#{mobile,jdbcType=VARCHAR})</if>
<if test="null!=address">,upper(#{address,jdbcType=VARCHAR})</if>
)
</insert>
<!--修改-->
<update id="toUpdate" parameterType="ActionValues"><if test="null!=id">
update 表明
<trim prefix="SET" suffixOverrides=",">
<if test="null != id">upper(id=#{id})</if>
<if test="null != name">,upper(name=#{name})</if>
<if test="null != sex">,upper(sex=#{sex})</if>
<if test="null != mobile">,upper(mobile=#{mobile})</if>
<if test="null != address">,upper(address=#{address})</if>
</trim>
where upper(id)=upper(#{id})
</if>
</update>
<!--删除-->
<delete id="toDelete" parameterType="ActionValues"><if test="null!=id">
delete from 表名 where upper(id)=upper(#{id})
</if>
</delete>
</mapper>
0 0
- XML的mybatis
- mybatis的xml配置
- Mybatis的xml
- mybatis的mapper XML
- mybatis中遇到的问题--mybatis.xml
- mybatis的mybatis-config.xml配置文件详解
- 【MyBatis】MyBatis-generator的配置文件 generatorConfig.xml
- 配置Mybatis的generator.xml
- mybatis的mapper.xml 小结
- Mybatis的xml配置实例
- mybatis的xml映射文件**
- eclipse的xml提示----mybatis
- mybatis的xml没有提示
- mybatis的xml中的sql
- MyBatis的xml配置文件笔记
- Mybatis的动态sql-----xml
- mybatis的核心xml文件配置mybatis-config.xml
- mybatis,xml
- html5移动设备浏览器触屏事件兼容处理
- 【Android 排错第二例】UnsupportedOperationException
- SparkSQL 使用jdbcRDD访问数据库
- VTK三维重建方法总结
- Reorder List
- XML的mybatis
- Dom4j中XPath相对路径的使用
- Jquery表单验证,免得自己写了
- 响应式开发总结
- 对偶(数学)
- Android开发之Frame动画(帧动画)
- values-11,values-14文件夹报错
- 数据流图解析
- 这是什么东西?