mybatis的mapper配置文件的一般写法。
来源:互联网 发布:办公隔断图片淘宝 编辑:程序博客网 时间:2024/05/01 00:08
mapper.xml大致如下:
<?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="com.hzcominfo.voucher.CommodityCategoryManager">
<cache-ref namespace="com.hzcominfo.dataggr.cloud" />
<insert id="insertCommodityCategoryManager" parameterType="com.hzcominfo.voucher.mapper.CommodityCategoryManager" keyProperty="id" >
INSERT INTO COMMODITY_CATEGORY_MANAGER (
<include refid="fields" />
) VALUES (
<include refid="values" />
)
</insert>
<update id="updateCommodityCategoryManager" parameterType="com.hzcominfo.voucher.mapper.CommodityCategoryManagerKey">
UPDATE COMMODITY_CATEGORY_MANAGER
<include refid="set" />
<include refid="where" />
</update>
<update id="deleteCommodityCategoryManager" parameterType="com.hzcominfo.voucher.mapper.CommodityCategoryManagerKey">
DELETE FROM COMMODITY_CATEGORY_MANAGER <include refid="where" />
</update>
<select id="selectCommodityCategoryManager" parameterType="String"
resultType="com.hzcominfo.voucher.mapper.CommodityCategoryManager">
SELECT * FROM COMMODITY_CATEGORY_MANAGER <include refid="where" />
</select>
<select id="selectCommodityCategoryManagerByCriteria" parameterType="net.butfly.albacore.dbo.criteria.Criteria"
resultType="com.hzcominfo.voucher.mapper.CommodityCategoryManagerKey">
SELECT CATEGORY_ID, USER_ID FROM COMMODITY_CATEGORY_MANAGER <include refid="where" />
</select>
<select id="countCommodityCategoryManagerByCriteria" parameterType="net.butfly.albacore.dbo.criteria.Criteria"
resultType="long">
SELECT count(*) FROM COMMODITY_CATEGORY_MANAGER <include refid="where" />
</select>
<sql id="fields">
<if test="categoryId!=null">CATEGORY_ID</if>
<if test="userId!=null">,USER_ID</if>
</sql>
<sql id="values">
<if test="categoryId!=null">#{categoryId}</if>
<if test="userId!=null">,#{userId}</if>
</sql>
<sql id="set">
<set>
<trim prefix="" prefixOverrides=",">
<if test="categoryId!=null">,CATEGORY_ID=#{categoryId}</if>
<if test="userId!=null">,USER_ID=#{userId}</if>
</trim>
</set>
</sql>
<sql id="where">
<where>
<trim prefix="" prefixOverrides="and|or" >
<if test="categoryId!=null">AND CATEGORY_ID=#{categoryId}</if>
<if test="userId!=null">AND USER_ID=#{userId}</if>
</trim>
</where>
</sql>
</mapper>
- mybatis的mapper配置文件的一般写法。
- Mybatis的mapper配置文件(一)
- mybatis的mapper配置文件配置oracle的判断是否成年的sql简洁写法。
- mybatis 模糊查询 mapper.xml的写法
- mybatis映射文件mapper.xml的写法。
- mybatis sql mapper 用map的写法
- mybatis批量insert的mapper xml写法
- MyBatis的Mapper配置文件的parameterType用法
- MyBatis的Mapper配置文件的parameterType用法
- 第三章 MyBatis Mapper 的 XML 配置文件
- 【SSM-MyBatis框架】Mapper.xml配置文件(mybatis的核心)
- mybatis一对多和多对一种mapper的写法
- mybatis中两个配置文件的写法
- Mybatis的Mapper代理方法和全局配置文件
- mybatis的mapper配置文件中的一些细节问题
- spring配置文件的一般写法(集成hibernate) (applicationContext.xml)
- mybatis的mapper
- mybatis mapper的配置
- Android SQLiteOpenHelper使用和源码详解
- HDU2175 汉诺塔9
- 深入理解Java虚拟机学习总结(二) 垃圾收集器与内存分配策略
- 小米网技术架构变迁实践
- CSS布局-负边距
- mybatis的mapper配置文件的一般写法。
- Maven仓库
- maven项目中测试代码
- NYOJ 8 一种排序 sort()应用
- 多线程
- MySQL快速入门(二)——Java进阶学习第十六天
- paint进阶
- ViewPager与ListView纵向滑动冲突的问题
- H.264 RTPpayload 格式------ H.264 视频 RTP 负载格式(包含AAC部分解析)