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] ...
随机推荐
- servlet上传文件报错(二)
1.具体报错如下: java.io.FileNotFoundException: D:\MyEclipse\workspace\FileUpload\WebRoot\upload (拒绝访问.) at ...
- 错误代码: 1248 Every derived table must have its own alias
1.错误描述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT stu_id, (SELECT stu_name FROM t ...
- Filter组件开发中的SDK基类分析
DirectShow SDK提供了一套开发Filter的基类源代码.基于这些基类开发Filter将大大简化开发过程. 1.CBaseObject 大部分SDK类都从CBaseObject类(参见com ...
- freemarker.template.TemplateException:Error parsing including template
1.错误描述 freemarker.template.TemplateException:Error parsing including template ftl/main.ftl:on line 6 ...
- 编写第一个Flutter App(翻译)
博客搬迁至http://blog.wangjiegulu.com RSS订阅:http://blog.wangjiegulu.com/feed.xml 以下代码 Github 地址:https://g ...
- MongoDB添加用户验证
Mongodb默认启动是不带认证,也没有账号,只要能连接上服务就可以对数据库进行各种操作,这样可不行.现在,我们得一步步开启使用用户和认证. 第一步,我们得定位到mongodb的安装目录.我本机的是C ...
- PHPExcel的使用
1.当然是下载PHPexcel的插件了 http://phpexcel.codeplex.com/ 2.应用插件 我把插件和需要用到的excel模板放的是不同文件夹的,excel我放在publi ...
- 浏览器全屏之requestFullScreen全屏与F11全屏
一.简介 浏览器全屏有两种方式,一种是HTML5新增的requestFullscree全屏,另一种是摁F11实现的全屏,本文将详解两种全屏的特点以及实现代码. 二.requestFullscreen全 ...
- Android热修复技术原理详解(最新最全版本)
本文框架 什么是热修复? 热修复框架分类 技术原理及特点 Tinker框架解析 各框架对比图 总结 通过阅读本文,你会对热修复技术有更深的认知,本文会列出各类框架的优缺点以及技术原理,文章末尾简单 ...
- Python Cookbook(第3版)中文版:15.20 处理C语言中的可迭代对象
15.20 处理C语言中的可迭代对象¶ 问题¶ 你想写C扩展代码处理来自任何可迭代对象如列表.元组.文件或生成器中的元素. 解决方案¶ 下面是一个C扩展函数例子,演示了怎样处理可迭代对象中的元素: s ...