How to have <association> as identifier in resultMap ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to have <association> as identifier in resultMap ?

babukota
This post has NOT been accepted by the mailing list yet.
<select id="retrieveBillsWithStatus" resultMap="CaseBillGroupBillIdentifier">
        SELECT A.CONT_NO,
               B.IF_ID,
               A.BILL_DUE_DT,
               A.BILL_DT,
               A.XBIL_KEY,
               A.CSBL_KEY,
               A.PR_BILL_CSBL_KEY
        FROM EXTR_BILLS A
        INNER JOIN BILL_GRP B ON A.BGRP_KEY = B.BGRP_KEY
        where A.REC_STAT_CD = #{bill_Status_Cd}
    </select>

<resultMap id="CaseBillGroupBillIdentifier" type="CaseBillGroupBillIdentifier">
        <association property="caseBillGroupBillKey" resultMap="caseBillGroupBillKey"/>
        <collection property="caseBillGroupXBills" resultMap="CaseBillGroupXBill"/>
    </resultMap>

    <resultMap id="caseBillGroupBillKey" type=".CaseBillGroupBillKey">
        <id column="CONT_NO" property="contractNumber" />
        <id column="IF_ID" property="billGroupID" />
        <id column="BILL_DUE_DT" property="billDueDate" />
        <id column="BILL_DT" property="billProduceDate" />
    </resultMap>

    <resultMap id="CaseBillGroupXBill" type="CaseBillGroupXBillKey">
        <id column="XBIL_KEY" property="xbillKey" />
        <result column="CSBL_KEY" property="caseBillKey" />
        <result column="PR_BILL_CSBL_KEY" property="priorCaseBillkey" />
    </resultMap>

when I get results I am getting two results with same caseBillGroupBillKey instead of one. Any help on queries?

{
        "caseBillGroupBillKey": {
            "contractNumber": "9050347",
            "billGroupID": "10001",
            "billDueDate": "2017-06-01 00:00:00",
            "billProduceDate": "2017-05-18 00:00:00"
        },
        "caseBillGroupXBills": [
            {
                "xbillKey": "23440308",
                "caseBillKey": "15683056",
                "priorCaseBillkey": "14688598"
            }
        ]
    },
    {
        "caseBillGroupBillKey": {
            "contractNumber": "9050347",
            "billGroupID": "10001",
            "billDueDate": "2017-06-01 00:00:00",
            "billProduceDate": "2017-05-18 00:00:00"
        },
        "caseBillGroupXBills": [
            {
                "xbillKey": "23440308",
                "caseBillKey": "15683056",
                "priorCaseBillkey": "14688598"
            }
        ]
    }