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] ...
随机推荐
- Exception sending context initialized event to listener instance of class
1.错误描述 严重:Exception sending context initialized event to listener instance of class org.springframew ...
- python datetime 与 time模块
time模块 tmie.strptime :将时间字符串转化为时间类型 格式:time.strptime(string[string[, format]) 结果可以利用利用time.tm_year 返 ...
- babel-runtime和babel-polyfill两者区别优缺点
先说两种方式的原理: babel-polyfill 使用场景 Babel 默认只转换新的 JavaScript 语法,而不转换新的 API.例如,Iterator.Generator.Set.Maps ...
- CodeIgniter怎么引入公共的头部或者尾部文件(实现随意引入或分区域创建header.html,bodyer.html,footer.html)
除非你天赋异禀,凡事基本对任何人来说都是开头难的,且开头的事情如果没有做好 往往会打掉一个人对于某件事的希望及其激情,所以咱们先从容易的事情开始慢慢建立自己 信心.后面的事情咱们再慢慢推进. 如果你是 ...
- PHP接收android传过来的图片
在android手机app上,上传图片,PHP服务端接收图片需要一下步骤 1 需要android 开发人员 把图片转成base64格式 2 PHP端接收转化后的base64字符串,然后进行转译 fun ...
- 使用mysql将备份的sql文件导入到数据库
一.背景 承接上一篇文章<如何使用mysqldump备份数据库>,数据库备份后将用于恢复或者在多个测试环境上迁移.下面描述如何通过批处理文件实现数据加载恢复. 二.环境准备 跟上一篇一样, ...
- Kendo UI ASP.Net MVC 实现多图片及时显示加上传(其中有借鉴别人的代码,自己又精简了一下,如有冒犯,请多原谅!)
View: <div class="demo-section k-content"> @(Html.Kendo().Upload() .Name("files ...
- BaaS 的由来(1)
百度百科是这么定义的, BaaS(后端即服务:Backend as a Service)公司为移动应用开发者提供整合云后端的边界服务.其实不仅是移动应用,现在更多的PC应用也同样适用移动端的标准. 在 ...
- C++学习-7
1.面向过程是:数据与操作分离,数据容易被意外修改 2.面向过程通过私有化的权限进行数据封装 3.类型后辍:类名 operator "" _XXXX(int data) 增加后缀 ...
- Promise,我们来实战
Promise的基础我就不说了,我更加关心的是Promise能带给我什么便利?这也是本文的内容所在. Promise.all 并发执行多个异步方法,统一返回结果,结果按照参数的顺序返回. const ...