<?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.data.dao.ExampleDao">
<resultMap id="exampleMap" type="Example">
<id property="id" column="id" />
<result property="name" column="name" />
<result property="sex" column="sex" />
<result property="age" column="age" />
<result property="city" column="city" />
<result property="birthday" column="birthday" />
</resultMap>
<sql id="findExampleBaseSql">
SELECT id, name, sex, age, city, birthday
</sql>
<!-- 分页查询条件sql -->
<sql id="searchExampleBaseSql">
<where>
1 = 1
<if test="condition.name != null">
AND name LIKE CONCAT('%','${condition.name}','%' )
</if>
<if test="condition.city != null">
AND city LIKE CONCAT('%','${condition.city}','%' )
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="listExample" resultMap="exampleMap" parameterType="java.util.Map">
<include refid="findExampleBaseSql" />
FROM example
<include refid="searchExampleBaseSql" />
<if test="sort != null">
ORDER BY #{sort} DESC
</if>
LIMIT #{first}, #{size}
</select>
<!-- 分页查询统计 -->
<select id="countExample" resultType="java.lang.Integer">
SELECT COUNT(*) FROM example
<include refid="searchExampleBaseSql" />
</select>
<!-- insertExample -->
<insert id="insertExample" parameterType="Example" useGeneratedKeys="true" keyProperty="id">
<![CDATA[
INSERT INTO example
(name, sex, age, city, birthday)
VALUES
(#{name}, #{sex}, #{age}, #{city}, #{birthday} )
]]>
</insert>
<!-- getExampleById -->
<select id="getExampleById" parameterType="java.lang.Long" resultMap="exampleMap">
<include refid="findExampleBaseSql" />
<![CDATA[
FROM example WHERE id = #{id}
]]>
</select>
<update id="updateExample" parameterType="Example">
<![CDATA[
UPDATE
example
SET
name = #{name},
sex = #{sex},
age = #{age},
city = #{city},
birthday = #{birthday}
WHERE
id = #{id};
]]>
</update>
</mapper>
- 浏览: 22573 次
- 来自: 杭州
相关推荐
十分宝贵的mybatis配置文件,包含最新的mybatis配置文件,以及mybatis开发文档,Log4j测试开发日志文件
Springboot用的Mybatis配置文件,配置了几个简单规则
Mybatis配置jar和超详细的笔记
E:\mybatis-generator-core-1.3.2\mybatis-generator-core-1.3.2\lib>java -jar mybat is-generator-core-1.3.2.jar -configfile generatorConfig.xml -overwrite MyBatis Generator finished successfully.
mybatis配置文件,用于SSM框架项目中的mybatis配置文件
09MyBatis配置 sqlMapConfig1
mybatis、mybatis详细设计、mybatis配置
springmvc+mybatis+oracle配置,整合
springboot配置文件模板:包括多环境开发布置,端口号配置,全局jackson配置,mysql数据库配置,oracle数据库配置,连接池配置,redis配置,redis链接池的配置,设置上传文件大小限制配置,全局格式化时间配置,https证书配置...
引入属性文件,注解扫描包,配置阿里数据连接池,性能配置,配置sqlSessionFactory,将spring与mybatis结合,指定mybatis核心控制文件,事务控制
mybatis 配置
包含mybatis配置文件 config与mapper,包含mybatis配置文件 config与mapper,包含mybatis配置文件 config与mapper
mybatis配置及测试项目:主要包含mybatis环境包,mysql驱动包,日志文件配置及环境测试案例
Spring+cxf配置接口+mybatis配置
springmvc+mybatis配置实例
mybatis配置文件生成jar包,可以在命令行中运行jar包,进行mapper配置文件的生成,及其简单方便
Mybatis配置的示例代码,整合了阿里的druid连接池。适合新手上手学习,也可以直接使用
mybatis配置文件模版
最新版的mybatis配置xml文件所需的dtd文件