最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

詳解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)文章

  • 關(guān)于Java父類沒有無參構(gòu)造方法子類處理方法

    關(guān)于Java父類沒有無參構(gòu)造方法子類處理方法

    父類無參構(gòu)造方法,子類不寫,其實(shí)會默認(rèn)調(diào)用父類的無參構(gòu)造方法也就是用super(),編譯運(yùn)行后,會打印出"子類會調(diào)用Father的第一個構(gòu)造方法,這篇文章給大家介紹關(guān)于Java父類沒有無參構(gòu)造方法子類處理方法,感興趣的朋友一起看看吧
    2024-01-01
  • Spring中使用copyProperties方法進(jìn)行對象之間的屬性賦值詳解

    Spring中使用copyProperties方法進(jìn)行對象之間的屬性賦值詳解

    這篇文章主要介紹了Spring中使用copyProperties方法進(jìn)行對象之間的屬性賦值詳解,使用org.springframework.beans.BeanUtils.copyProperties方法進(jìn)行對象之間屬性的賦值,避免通過get、set方法一個一個屬性的賦值,需要的朋友可以參考下
    2023-12-12
  • Java幾種常用的斷言風(fēng)格你怎么選

    Java幾種常用的斷言風(fēng)格你怎么選

    這篇文章主要介紹了Java幾種常用的斷言風(fēng)格你怎么選,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • SpringCloud?Bus組件的使用配置詳解

    SpringCloud?Bus組件的使用配置詳解

    bus稱之為springcloud中消息總線,主要用來在微服務(wù)系統(tǒng)中實(shí)現(xiàn)遠(yuǎn)端配置更新時通過廣播形式通知所有客戶端刷新配置信息,避免手動重啟服務(wù)的工作,這篇文章主要介紹了SpringCloud?Bus組件的使用,需要的朋友可以參考下
    2022-03-03
  • JAVA函數(shù)的定義、使用方法實(shí)例分析

    JAVA函數(shù)的定義、使用方法實(shí)例分析

    這篇文章主要介紹了JAVA函數(shù)的定義、使用方法,結(jié)合實(shí)例形式分析了JAVA函數(shù)的基本概念、功能、原理、定義、使用方法與操作注意事項,需要的朋友可以參考下
    2020-04-04
  • Map獲取鍵值,Map的幾種遍歷方法總結(jié)(推薦)

    Map獲取鍵值,Map的幾種遍歷方法總結(jié)(推薦)

    下面小編就為大家?guī)硪黄狹ap獲取鍵值,Map的幾種遍歷方法總結(jié)(推薦)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-04-04
  • Java中的CyclicBarrier循環(huán)柵欄深入解析

    Java中的CyclicBarrier循環(huán)柵欄深入解析

    這篇文章主要介紹了Java中的CyclicBarrier循環(huán)柵欄深入解析,CycleBarrier 它就相當(dāng)于是一個柵欄,所有線程在到達(dá)柵欄后都需要等待其他線程,等所有線程都到達(dá)后,再一起通過,需要的朋友可以參考下
    2023-12-12
  • Java如何重寫object類的equals方法詳解

    Java如何重寫object類的equals方法詳解

    這篇文章主要給大家介紹了關(guān)于Java如何重寫object類的equals方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • java中functional interface的分類和使用詳解

    java中functional interface的分類和使用詳解

    這篇文章主要介紹了java中functional interface的分類和使用,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2020-04-04
  • SpringBoot中操作Redis及工具類的封裝詳解

    SpringBoot中操作Redis及工具類的封裝詳解

    在我們項目開發(fā)中總是免不了會使用緩存,Redis現(xiàn)在基本是我們公司中非常常見的緩存方案,包括在用戶token的緩存,熱點(diǎn)信息的緩存等,這篇文章主要講講在SpringBoot項目中如何去操作Redis,及最后工具類的封裝
    2023-05-05

最新評論

乐安县| 乐东| 金华市| 定州市| 响水县| 定襄县| 邓州市| 洞口县| 玉山县| 闽侯县| 赣州市| 盐城市| 五原县| 福建省| 连山| 华坪县| 九龙县| 广西| 汉中市| 武穴市| 舒兰市| 工布江达县| 丘北县| 衡东县| 定兴县| 梁平县| 济阳县| 屏东县| 津市市| 三都| 陆良县| 原平市| 米林县| 安义县| 会同县| 天水市| 遂平县| 玉林市| 南江县| 富顺县| 福贡县|