mybatis 配置文件 学习笔记
2018-02-11 17:44
323 查看
//局部配置文件
<?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="cn.bdqn.entity.UserDao">
<select id="getAll" resultType="cn.bdqn.entity.mybatisDemo">
select * from mybatis
</select>
<!-- 返回List(<Map<String,Object>> -->
<!-- 优点是不需创建实体类 -->
<select id="getAll2" resultType="Map">
select * from mybatis
</select>
<!-- 带有查询条件的sql语句 -->
<!-- 一个查询条件的sql语句 -->
<select id="getAll3" resultType="Map" parameterType="Integer">
select * from mybatis where id=#{0}
</select>
<!-- 带多个查询条件的sql语句 -->
<select id="getAll4" resultType="Map" parameterType="Map">
select *from mybatis where id=#{id} and name=#{name}
</select>
<select id="getAll5" resultType="Map" parameterType="cn.bdqn.entity.mybatisDemo">
select *from mybatis where id=#{id}
</select>
<!-- 模糊查询 -->
<select id="getAll6" resultType="map">
select * from mybatis where password like '%2%';
</select>
</mapper>
<?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="cn.bdqn.entity.UserDao">
<select id="getAll" resultType="cn.bdqn.entity.mybatisDemo">
select * from mybatis
</select>
<!-- 返回List(<Map<String,Object>> -->
<!-- 优点是不需创建实体类 -->
<select id="getAll2" resultType="Map">
select * from mybatis
</select>
<!-- 带有查询条件的sql语句 -->
<!-- 一个查询条件的sql语句 -->
<select id="getAll3" resultType="Map" parameterType="Integer">
select * from mybatis where id=#{0}
</select>
<!-- 带多个查询条件的sql语句 -->
<select id="getAll4" resultType="Map" parameterType="Map">
select *from mybatis where id=#{id} and name=#{name}
</select>
<select id="getAll5" resultType="Map" parameterType="cn.bdqn.entity.mybatisDemo">
select *from mybatis where id=#{id}
</select>
<!-- 模糊查询 -->
<select id="getAll6" resultType="map">
select * from mybatis where password like '%2%';
</select>
</mapper>
相关文章推荐
- Mybatis 源码学习笔记(八)mapper映射文件配置之select、resultMap
- Mybatis学习笔记-核心配置文件概述
- mybatis学习笔记--mapper配置文件中大于小于怎么处理
- Mybatis学习笔记-CURD(基于配置文件的方式)
- SqlMapConfig.xml配置文件---Mybatis学习笔记(七)
- mybatis学习笔记——Xml配置文件
- 电商平台学习笔记(四)——Spring配置Mybatis简化DAO层省略Mybatis核心配置文件
- SqlMapConfig.xml配置文件---Mybatis学习笔记(七)
- Mybatis学习笔记(二)-----查询sql的配置文件
- MyBatis学习笔记(三)——优化MyBatis配置文件中的配置
- mybatis学习笔记(十二) 映射配置文件详解
- Mybatis学习笔记-CURD(基于配置文件的方式)
- MyBatis学习笔记(一)——配置文件中的别名以及mapper中的namespace
- mybatis学习笔记--配置文件+注解完整案例
- mybatis学习笔记(二)配置文件
- 【知了堂学习笔记】——mybatis核心配置文件和映射配置文件
- Mybatis学习笔记(二)配置文件
- MyBatis For .NET学习笔记[2]:配置环境
- Autofac学习笔记之-配置文件实现组件注册
- Unity学习笔记1-以配置文件方式注册组件