mybatis整合oracle 实现一对多查询 备注?
<resultMap type="com.asiainfo.channel.model.weeklyNewspaper.WorkReportInfo" id="WorkReportInfoMap">
<result property="reportId" column="report_id" />
<result property="reportType" column="report_type" />
<result property="completeContent" column="complete_content" />
<result property="needComplete" column="need_complete" />
<result property="needHelp" column="need_help" />
<result property="beginDt" column="begin_dt" javaType="date" jdbcType="DATE"/>
<result property="endDt" column="end_dt" javaType="date" jdbcType="DATE"/>
<result property="createStaff" column="create_staff" />
<result property="createDt" column="createDt" javaType="date" jdbcType="DATE"/>
<collection property="reportFileInfoList" ofType="com.asiainfo.channel.model.weeklyNewspaper.ReportFileInfo"
select="getReportFileInfoList" column="report_id">
</collection>
<collection property="workReportSendListInfoList" ofType="com.asiainfo.channel.model.weeklyNewspaper.WorkReportSendListInfo"
select="getWorkReportSendListInfoList" column="report_id">
</collection>
</resultMap>
<!-- 查询工作报告详情 映射到内部集合 -->
<select id="queryworkReportDetail" parameterType="map" resultMap="WorkReportInfoMap">
select report_id ,
report_type ,
complete_content,
need_complete ,
need_help ,
begin_dt ,
end_dt ,
create_staff ,
create_dt
from work_report t
where 1=1
<include refid="queryWorkReportListCondition"/>
</select>
<!-- 一对多映射使用的子查询 -->
<select id="getReportFileInfoList" parameterType="int" resultType="com.asiainfo.channel.model.weeklyNewspaper.ReportFileInfo">
select t.report_file_id,
t.report_id,
t.file_uuid,
t.file_name,
t.FILE_DIR,
t.FILE_TYPE,
t.FILE_POST_FIX
from report_file t
where t.report_id = #{reportId}
</select>
<!-- 一对多映射使用的子查询 -->
<select id="getWorkReportSendListInfoList" parameterType="int" resultType="com.asiainfo.channel.model.weeklyNewspaper.WorkReportSendListInfo">
select send_id,
report_id,
receive_name,
receive_code,
receive_staff_id,
receive_mail,
receive_num
from work_report_send_list t
where t.report_id = #{reportId}
</select>
<sql id="queryWorkReportListCondition">
<!-- 类型 -->
<if test="workReportCycle != null and workReportCycle != '' ">
and t.REPORT_TYPE = #{workReportCycle}
</if>
<!-- 地区 -->
<if test="commonRegionId != null and commonRegionId != '' ">
and t.COMMON_REGION_ID IN (
select COMMON_REGION_ID from common_region
CONNECT BY PRIOR COMMON_REGION_ID=UP_REGION_ID
START WITH COMMON_REGION_ID=#{commonRegionId}
)
</if>
<!-- 开始时间 -->
<if test="beginDt != null and beginDt != '' ">
and t.BEGIN_DT > to_date(#{beginDt},'yyyy-mm-dd hh24:mi:ss')
</if>
<!-- 截止时间 -->
<if test="endDt != null and endDt != '' ">
and t.BEGIN_DT < to_date(#{endDt},'yyyy-mm-dd hh24:mi:ss')
</if>
<!-- 人名 模糊查询 staffName -->
<if test="staffName != null and staffName != '' ">
and t.create_staff like concat(concat('%',#{staffName}),'%')
</if>
<!-- 主键ID -->
<if test="reportId != null and reportId != '' ">
and t.report_id = #{reportId}
</if>
</sql>
mybatis整合oracle 实现一对多查询 备注?的更多相关文章
- mybatis的一对一,一对多查询,延迟加载,缓存介绍
一对一查询 需求 查询订单信息关联查询用户信息 sql语句 /*通过orders关联查询用户使用user_id一个外键,只能关联查询出一条用户记录就可以使用内连接*/ SELECT orders.*, ...
- JAVAEE——Mybatis第二天:输入和输出映射、动态sql、关联查询、Mybatis整合spring、Mybatis逆向工程
1. 学习计划 1.输入映射和输出映射 a) 输入参数映射 b) 返回值映射 2.动态sql a) If标签 b) Where标签 c) Sql片段 d) Foreach标签 3.关联查询 a) 一对 ...
- MyBatis动态条件、一对多、整合spring(二)
输入映射和输出映射 Mapper.xml映射文件定义了操作数据库的sql,每一个sql是一个statement,映射文件是mybatis的核心. parameterType输入类型 1.传递简单类型 ...
- Mybatis oracle多表联合查询分页数据重复的问题
Mybatis oracle多表联合查询分页数据重复的问题 多表联合查询分页获取数据时出现一个诡异的现象:数据总条数正确,但有些记录多了,有些记录却又少了甚至没了.针对这个问题找了好久,最后发现是由于 ...
- mybatis由浅入深day02_3一对多查询
3 一对多查询 3.1 需求(查询订单及订单明细的信息) 查询订单及订单明细的信息. 3.2 sql语句 确定主查询表:订单表 确定关联查询表:订单明细表 在一对一查询基础上添加订单明细表关联即可. ...
- mybatis中实现一对一,一对多查询
在实际的开发中我们经常用到的是一对一查询和一对多查询.而多对多的实现是通过中间来实现,这里就没有给出来了 比如: 订单和用户是一对一的关系(一个订单只能对应一个用户) 订单和订单明细是一对多的关系(一 ...
- mybatis 一对多查询 集合创建空对象的问题
在做 mybatis 一对多查询的时候, resultMap 里面用到了集合标签 collection ,后来发现 当该条数据没有子集的时候, collection 会自动创建一个属性都是null的对 ...
- springboot整合mybatis连接oracle
pom.xml: <!-- 链接:https://pan.baidu.com/s/1agHs5vWeXf90r3OEeVGniw 提取码:wsgm --> <dependency&g ...
- Mybatis一对多查询得不到多方结果
一对多查询:一个年级对应多个学生,现在要查询年级(带学生)信息. 查询结果: [main] INFO com.java1234.service.GradeTest - 查询年级(带学生)[main] ...
随机推荐
- The struts dispatcher cannot be found
1.错误描述 严重:Servlet.service() for servlet jsp threw exception The struts dispatcher cannot be found.Th ...
- JDBC连接池(三)DBCP连接池
JDBC连接池(三)DBCP连接池 在前面的随笔中提到 了 1.JDBC自定义连接池 2. C3P0连接池 今天将介绍DBCP连接池 第一步要导入jar包 (注意:mysql和mysql 驱动 ...
- 生物结构变异分析软件meerkat 0.189使用笔记(一)
一.准备工作 meerkat 0.189版本和以前的版本相比,支持bwa mem 输出的bam文件,还支持全外显子数据count SV. meerkat原理:参见http://compbio. ...
- jQuery对象与js对象互相转换
两种转换方式将一个jQuery对象转换成js对象:[index]和.get(index); (1)jQuery对象是一个数据对象,可以通过[index]的方法,来得到相应的js对象. 如:var $v ...
- python爬取youtube视频 多线程 非中文自动翻译
声明:我写的所有文章都是发在博客园的,我看到其他复制粘贴过去的 连个出处也不写,直接打上自己的水印...真是没的说了. 前言:前段时间搞了一些爬视频的项目,代码都写好了,这里写文章那就在来重新分析一遍 ...
- 登录对话框(窗体程序)--JAVA基础
1.用到的JFrame(框架)类对象(这里设JFrame类对象是frame)的方法有: frame.add(); 添加组件到frame框架中 frame.setVisible(); 设置框架是否可见 ...
- 【BZOJ4195】【NOI2015】程序自动分析(并查集)
[BZOJ4195][NOI2015]程序自动分析(并查集) 题面 Description 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设 ...
- Golang的CSP很酷?其实.NET也可以轻松完成
说起Golang(后面统称为Go),就想到他的高并发特性,在深入一些就是 Goroutine.在大家被它优雅的语法和简洁的代码实现的高并发程序所折服时,其实C#/.NET也可以很容易的做到.今天我们来 ...
- vue.js 配置移动端的url Scheme和iOS端配置url Scheme
假如urlScheme:baibai:// 一.vue.js端的配置: 1.通过html标签跳转: <p href="baibai://"></p> 2.通 ...
- Win10_x86_x64PE维护光盘——我用过最好用的PE
先感谢hongxj和fish2006两位大大提供的PE. 先放出所有工具的下载地址: hongxj的PE:https://yunpan.cn/crAw6HS6ar9ck 访问密码 4a4e fish ...