欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解mybatis collection標(biāo)簽一對多的使用

 更新時間:2020年06月16日 14:58:33   作者:love_Watermelon  
這篇文章主要介紹了mybatis collection標(biāo)簽一對多的使用,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

查詢, 結(jié)果集為AssociatedInfo:

<select id="queryReportAssociatedAcp" resultMap="AssociatedInfo">
 
    SELECT
    r.requisition_number AS business_code,
    r.id AS header_id,
    r.document_type_id AS reportTypeId,
    r.applicant_id as employeeId
    FROM
    fec_expense.exp_report_payment_schedule b,fec_expense.exp_report_header r
    WHERE
    b.exp_report_header_id=r.id and r.`status`=1004
    and
    b.frozen_flag ="Y"
    and r.applicant_id=#{applicationId}
    <if test="reportNumber!=null and reportNumber != ''">
      AND r.requisition_number LIKE concat(
      '%',
      concat(#{reportNumber,jdbcType=VARCHAR}, '%'))
    </if>
    <if test="documentTypeId !=null and reportNumber != ''">
      AND r.document_type_id = #{documentTypeId}
    </if>
    <if test="formTypes != null and formTypes.size > 0">
      AND r.document_type_id IN
      <foreach collection="formTypes" item="formId" open="(" separator="," close=")">
        #{formId}
      </foreach>
    </if>
    AND (
    b.amount - ( SELECT
    COALESCE(sum( c.write_off_amount ), 0) AS write_off_amount
    FROM
    csh_write_off c
    WHERE
    c.document_header_id = b.exp_report_header_id
    AND c.document_line_id = b.id
    AND ( c.STATUS = 'Y' OR ( c.STATUS = 'P' AND c.operation_type = 'WRITE_OFF' ) )
    ) - (
    SELECT
    COALESCE(sum( a.amount ), 0) AS commit_amount
    FROM
    csh_data_relation_acp a
    WHERE
    a.report_head_id = b.exp_report_header_id
    AND a.report_line_id = b.id
    AND a.document_type = 'ACP_REQUISITION'
    ) > 0
    )
    GROUP BY
    r.requisition_number,
    b.exp_report_header_id,
    r.document_type_id,
    b.applicant_id
    ORDER BY
    r.requisition_number
 
  </select>

結(jié)果集 AssociatedInfo: 使用collection 實(shí)現(xiàn)1對多的場景, CashDataPublicReportHeaderDTO實(shí)體里包含一個行的集合List<CashDataPublicReportLineDTO> lines: 

<resultMap id="AssociatedInfo" type="com.hand.hcf.app.payment.web.dto.CashDataPublicReportHeaderDTO">
    <result column="header_id" property="reportHeadId"/>
    <result column="business_code" property="reportNumber"/>
    <result column="form_name" property="reportTypeName"/>
    <collection property="lineList" column="{headerId=header_id}"
          ofType="ArrayList" select="getPaymentInfo"/>
  </resultMap>
  <select id="getPaymentInfo" resultType="com.hand.hcf.app.payment.web.dto.CashDataPublicReportLineDTO">
    SELECT
	temp.id scheduleLineId,
	"" AS cshTransactionId,
	temp.amount,
	temp.associated_amount associatedAmount,
	(
	temp.amount - temp.associated_amount - (
SELECT COALESCE
	( sum( c.write_off_amount ), 0 ) AS write_off_amount
FROM
	csh_write_off c
WHERE
	c.document_header_id = temp.exp_report_header_id
	AND c.document_line_id = temp.id
	AND c.document_type = "PUBLIC_REPORT"
	AND ( c.STATUS = 'Y' OR ( c.STATUS = 'P' AND c.operation_type = 'WRITE_OFF' ) )
	)
	) AS availableAmount,
	temp.exp_report_header_id expReportHeaderId,
	0 AS scheduleLineNumber,
	temp.company_id companyId,
	temp.currency_code currency,
	temp.description description,
	temp.exchange_rate exchangeRate,
	temp.payment_schedule_date schedulePaymentDate,
	temp.payment_method paymentMethod,
	temp.payment_type,
	temp.prop_flag prop_flag,
	temp.csh_transaction_class_id cshTransactionClassId,
	( SELECT ctc.description FROM csh_transaction_class ctc WHERE ctc.id = temp.csh_transaction_class_id ) AS cshTransactionClassName,
	temp.cash_flow_item_id cashFlowItemId,
	temp.payee_category payeeCategory,
	temp.payee_id payeeId,
	temp.account_number accountNumber,
	temp.account_name accountName,
	temp.bank_code bankCode,
	temp.bank_name bankName,
	temp.bank_code bankLocationCode,
	temp.bank_name bankLocationName,
	"" provinceCode,
	"" provinceName,
	""cityCode,
	"" cityName,
	 (select c.type_code from csh_transaction_class c where c.id=temp.csh_transaction_class_id ) cshTransactionTypeCode,
	""contractHeaderId
FROM
	(
SELECT
  b.*,
	(
SELECT COALESCE
	( sum( a.amount ), 0 ) AS associated_amount
FROM
	csh_data_relation_acp a
WHERE
	a.report_head_id = b.exp_report_header_id
	AND a.report_line_id = b.id
	AND a.document_type = 'ACP_REQUISITION'
	) AS associated_amount
FROM
	fec_expense.exp_report_payment_schedule b ,fec_expense.exp_report_header r
WHERE
	b.frozen_flag = "Y"
	and b.exp_report_header_id=r.id
	AND b.exp_report_header_id = #{headerId}
	) temp
 
  </select>

包含列表的實(shí)體類 CashDataPublicReportHeaderDTO :

package com.hand.hcf.app.payment.web.dto;
 
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
 
import java.time.ZonedDateTime;
import java.util.List;
 
@Data
public class CashDataPublicReportHeaderDTO {
 
  @JsonSerialize(using = ToStringSerializer.class)
  private Long reportHeadId;//報賬單頭ID
 
  private String reportNumber;//報賬單編號
 
  private String reportTypeName;//報賬單類型
  @JsonSerialize(using = ToStringSerializer.class)
  private Long reportTypeId;// 報賬單類型ID
 
  private List<CashDataPublicReportLineDTO> lineList;//報賬單計劃付款行
 
  @JsonSerialize(using = ToStringSerializer.class)
  private Long employeeId;//員工ID
  private String employeeName;//員工名稱
 
  private ZonedDateTime requisitionDate; // 申請日期
}

總結(jié)

到此這篇關(guān)于mybatis collection標(biāo)簽一對多的使用的文章就介紹到這了,更多相關(guān)mybatis collection標(biāo)簽內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • jQuery.event.trigger()的簡單解釋

    jQuery.event.trigger()的簡單解釋

    今天小編就為大家分享一篇關(guān)于jQuery.event.trigger()的簡單解釋,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧
    2018-10-10
  • Java正則之貪婪匹配、惰性匹配

    Java正則之貪婪匹配、惰性匹配

    這篇文章主要介紹了Java正則之貪婪匹配、惰性匹配的相關(guān)資料,需要的朋友可以參考下
    2015-03-03
  • Spring @value用法示例詳解

    Spring @value用法示例詳解

    這篇文章主要介紹了Spring-@value用法詳解,為了簡化讀取properties文件中的配置值,spring支持@value注解的方式來獲取,這種方式大大簡化了項目配置,提高業(yè)務(wù)中的靈活性,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2022-08-08
  • 淺析對Spring?aware接口理解

    淺析對Spring?aware接口理解

    通過aware接口可以獲取Spring容器相關(guān)信息,但這樣會與Spring容器耦合,這篇文章主要介紹了Spring?aware接口理解,需要的朋友可以參考下
    2022-08-08
  • Go Java算法之找不同示例詳解

    Go Java算法之找不同示例詳解

    這篇文章主要為大家介紹了Go Java算法之找不同示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • 如何使用JDBC連接數(shù)據(jù)庫并執(zhí)行SQL語句

    如何使用JDBC連接數(shù)據(jù)庫并執(zhí)行SQL語句

    JDBC是Java數(shù)據(jù)庫連接的縮寫,是Java程序與數(shù)據(jù)庫進(jìn)行交互的標(biāo)準(zhǔn)API。JDBC主要包括Java.sql和javax.sql兩個包,通過DriverManager獲取數(shù)據(jù)庫連接對象Connection,并通過Statement或PreparedStatement執(zhí)行SQL語句
    2023-04-04
  • 為什么Java項目中別用!=null做判空

    為什么Java項目中別用!=null做判空

    本文主要介紹了為什么Java項目中別用!=null做判空,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-04-04
  • Java中的線程死鎖是什么?如何避免?

    Java中的線程死鎖是什么?如何避免?

    這篇文章主要介紹了Java中線程死鎖的相關(guān)資料,以及避免死鎖的方法,幫助大家更好的理解和使用Java,感興趣的朋友可以了解下
    2020-09-09
  • SpringSecurity的防Csrf攻擊實(shí)現(xiàn)代碼解析

    SpringSecurity的防Csrf攻擊實(shí)現(xiàn)代碼解析

    這篇文章主要介紹了SpringSecurity的防Csrf攻擊實(shí)現(xiàn)代碼解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2020-03-03
  • logback TimeBasedRollingPolicy按天生成日志源碼解析

    logback TimeBasedRollingPolicy按天生成日志源碼解析

    這篇文章主要為大家介紹了logback TimeBasedRollingPolicy按天生成日志源碼解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11

最新評論