Mybatis之collection嵌套查询mapper文件写法
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="maserati.dao.meta.list.ListSchemaMapper">
<resultMap id="BaseResultMap" type="maserati.dao.meta.list.entity.ListSchemaEntity">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="mod_name" property="modName" jdbcType="VARCHAR"/>
<result column="prop_name" property="propName" jdbcType="VARCHAR"/>
<result column="prop_desc" property="propDesc" jdbcType="VARCHAR"/>
<result column="del_flag" property="delFlag" jdbcType="BIT"/>
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
</resultMap> <resultMap id="ListMeta" type="maserati.dao.meta.list.entity.ListMeta">
<result column="mod_name" property="modName" jdbcType="VARCHAR"/>
<result column="mod_desc" property="modTitle" jdbcType="VARCHAR"/>
<collection property="tHeads" ofType="maserati.dao.meta.list.entity.PropMeta"
select="selectTableHeads" column="mod_name" javaType="ArrayList"/>
</resultMap>
<resultMap id="TableHead" type="maserati.dao.meta.list.entity.PropMeta">
<result property="propName" column="prop_name" jdbcType="VARCHAR"/>
<result property="propDesc" column="prop_desc" jdbcType="VARCHAR"/>
<result property="propType" column="prop_type" jdbcType="VARCHAR"/>
</resultMap> <sql id="Base_Column_List">
id, mod_name, prop_name, prop_desc, del_flag, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from t_list_schema
where id = #{id,jdbcType=INTEGER}
</select> <select id="selectAllProdListMeta" resultMap="ListMeta">
select
distinct mod_name,mod_desc
from t_list_schema where mod_name in ('loan','credit_card','other_prod') and del_flag = 0
</select> <select id="selectTableHeads" resultMap="TableHead" parameterType="java.lang.String">
select prop_name,prop_desc,prop_type
from t_list_schema where mod_name='${value}' and del_flag = 0 order by sort_index
</select> <select id="selectPropNameByModName" resultType="java.lang.String" parameterType="java.lang.String">
select prop_name from t_list_schema where mod_name=#{value} and del_flag=0
order by sort_index
</select> <select id="selectTableHeadsByModName" resultMap="TableHead" >
select prop_name,prop_desc,prop_type from t_list_schema where mod_name=#{value} and del_flag=0
order by sort_index
</select>
</mapper>
Mybatis之collection嵌套查询mapper文件写法的更多相关文章
- Mybatis框架的模糊查询(多种写法)、删除、添加(四)
学习Mybatis这么多天,那么我给大家分享一下我的学习成果.从最基础的开始配置. 一.创建一个web项目,看一下项目架构 二.说道项目就会想到需要什么jar 三.就是准备大配置链接Orcl数据库 & ...
- 【坑】Mybatis 多次逆向工程生成mapper文件
在使用 mybatis 逆向工程的时候,多次逆向工程生成的文件,是不会产生覆盖的,而是追加: 假如,你第一次逆向,发生数据库的某个字段类型错了,修改以后再次逆向,那么得到的 mapper文件,将是 2 ...
- Mybatis源码分析之Mapper文件解析
感觉CSDN对markdown的支持不够友好,总是伴随各种问题,很恼火! xxMapper.xml的解析主要由XMLMapperBuilder类完成,parse方法来完成解析: public void ...
- mybatis中collection子查询注入参数为null
具体实现参照网上,但是可能遇到注入参数为null的情况,经过查阅及自己测试记录一下: 子查询的参数中,有<if test="">之类,需要指定别名,通过 http:// ...
- mybatis两种嵌套查询方式
1,推荐用第一种 <select id="getTeacher2" resultMap="TeacherStudent"> select s.id ...
- mybatis 关联查询和嵌套查询的简单示例
两个表: Customer 顾客表 create table if not exists customer( customer_id int primary key auto_increment, f ...
- mybatis 嵌套查询与懒加载
懒加载:对于页面有很多静态资源的情况下(比如网商购物页面),为了节省用户流量和提高页面性能,可以在用户浏览到当前资源的时候,再对资源进行请求和加载. fetchType="lazy" ...
- mybatis的嵌套查询与嵌套结果查询的不同
原文:https://blog.csdn.net/qq_39706071/article/details/85156840 实体类: 嵌套查询mapper方法:嵌套查询的弊端:即嵌套查询的N+1问题尽 ...
- Mybatis之collection与association标签
collection与association标签的功能就是为了解决查询条件映射到一个类或一个集合上,适用于对于多对一,一对多的映射结果,现在我们就探究其具体使用吧. 环境搭建: 数据库搭建 CREAT ...
随机推荐
- C# GDI+双缓冲技术
我想有很多搞图形方面的朋友都会用到双缓冲技术的时候,而且有的时候她的确是个头疼的问题.最近我也要用双缓冲技术,程序怎么调试都不合适,当要对图形进行移动时,总是会出现闪烁抖动.在网上找了些资料,说得都不 ...
- Java NIO6:选择器1——理论篇
一.选择器 选择器提供选择执行已经就绪的任务的能力,这使得多元I/O成为了可能,就绪执行和多元选择使得单线程能够有效地同时管理多个I/O通道. 某种程度上来说,理解选择器比理解缓冲区和通道类更困难一些 ...
- ESP8266开发综合篇第十四节(LUA)-8266作为TCP服务器,Android客户端连接,显示温湿度,控制继电器
前几节先略过,我先补充上大部分人迫切的需求 编写Android TCP客户端 用Android Studio 先做一下界面 然后放一个输入对话框,因为没有显示出来这个控件.所以就手写 剩下的自己研究 ...
- UIImageView - BNR
继续上节UINavigationController - BNR. 打开BNRDetailViewController.xib文件,向view中添加UIImageView对象,选中该对象,通过Attr ...
- Groovy语言学习--语法基础(2)
集合和闭包 因为之前没接触过C++等,对指针也一窍不通.个人不成熟的了解 闭包是一种数据类型,可以很方便的执行一段独立的代码 简化方法的调用 package groovy /** * Groovy容器 ...
- 【C#复习总结】细说委托
1 前言 本系列会将[委托] [匿名方法][Lambda表达式] [泛型委托] [表达式树] [事件]等基础知识总结一下.(本人小白一枚,有错误的地方希望大佬指正) 系类1:细说委托 系类2:细说匿名 ...
- Python股票分析系列——数据整理和绘制.p2
该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第2部分. 在本教程中,我们将利用我们的股票数据进一步分解一些基本的数据操作和可视化. 我们将要 ...
- 百度软件开发实习生c++方向面经(一面)
百度2017实习生软件开发(cpp方向) 首先说一下岗位.分为软件开发,开发测试,前端,机器学习数据挖掘,移动开发,据我观察,报的人数来看,软件开发最多,移动开发和开发测试较少.百度前台还准备了吃的喝 ...
- Python-生成器_36
#生成器函数 def generator(): print(1) return 'a' ret = generator() print(ret) #只要含有yield关键字的函数都是生成器函数 # y ...
- 批量采集世纪佳缘会员图片及winhttp异步采集效率
原始出处:http://www.cnblogs.com/Charltsing/p/winhttpasyn.html 最近老有人问能不能绕过世纪佳缘的会员验证来采集图片,我测试了一下,发现是可以的. 同 ...