Everything was working with MyBatis and the objects I have outlined, until I introduced a LIST within the first child List object. So now, my structure is:
I've tried a number of approaches through the XML mapper, with variations on resultMap configurations. This is what I have currently:
<resultMap id="saleTransaction" type="com.company.sale.domain.Sale" autoMapping="true">
<result property="transactionNumber" column="TRANSACTION_ID"/>
<result property="salesTrip.tripDate" column="TRIP_DATE"/>
<result property="salesTrip.tripNumber" column="TRIP_NUMBER"/>
<result property="salesTrip.tripOriginTerminal.iataCode" column="ORIGIN_IATA_CODE"/>
<result property="salesTrip.tripOriginTerminal.city" column="ORIGIN_CITY_NAME"/>
<result property="salesTrip.tripDestinationTerminal.iataCode" column="DESTINATION_IATA_CODE"/>
<result property="salesTrip.tripDestinationTerminal.city" column="DESTINATION_CITY_NAME"/>
<collection property="salesTransactionPayments" ofType="SalesTransactionPayment">
<result property="amount" column="AMOUNT"/>
<result property="creditCard.cardNumber" column="CC_NUMBER"/>
<result property="creditCard.nameOnCard" column="CCHOLDER_NAME"/>
</collection>
<collection property="salesTransactionItems" column="TRANSACTION_ID" ofType="SalesTransactionItem" select="getSaleItems">
<result property="item" column="ITEM"/>
<result property="price" column="PRICE"/>
<result property="qty" column="QTY"/>
<association property="salesTransactionTaxRates" column="ID" resultMap="taxResult" />
</collection>
</resultMap>
<resultMap id="taxResult" type="com.guestlogix.sale.domain.SalesTransactionTaxRate" autoMapping="true">
<result property="code" column="code"/>
<result property="rate" column="rate"/>
<result property="isFixed" column="isFixed"/>
</resultMap>
The Object SalesTransactionTaxRate is a child to SalesTransactionItem, which in turn is a child of the parent Sale object. SalesTransactionItem is a LIST and then SalesTransactionTaxRate is a LIST as well. There can be many taxes for an ITEM and there can be many ITEMS for a SALE.
I've tried mapping SalesTransactionTaxRate as a collection within SalesTransactionItem collection, again to no avail. When I use that approach, it does not even register that SalesTransactionTaxRate is contained within SalesTransactionItem at all in the IDE. Otherwise, there is autocomplete for the other objects and properties.
All the documentation shows that a collection within a collection is possible, it just does not seem to be working for me for some reason.
Any help or advice is hugely appreciated.