我有SrcObject中的StateTax和LocalTax集合。這需要映射到StateLocalTax的集合。在SrcObject中,如果我有三個SrcStateTax和兩個SrcLocalTax,我想將它們映射到一個StateLocalTax集合,它將包含四個元素。此集合的三個元素將包含具有null destLocalTaxGroup的stateTax信息,並且一個元素將包含具有兩個LocalTax信息的destLocalTaxGroup的集合。推土機深集合映射
public class SrcObject {
private List<SrcStateTax> srcStateTaxGroup;
private List<SrcLocalTax> srcLocalTaxGroup;
//Getter setter
}
public class SrcStateTax {
private String srcStateCode;
private String srcStateTaxAmount;
……
//Getter setter
}
public class SrcLocalTax {
private String srcLocalCode;
private String srcLocalTaxAmt;
……
//Getter setter
}
目標對象是
public class DestObject {
private List<StateLocalTax> stateLocalTaxGroup;
……..
//Getter setter
}
public class StateLocalTax {
private String destStateCode;
private String destStateTaxAmount;
…….
private List<DestLocalTax> destLocalTaxGroup;
//Getter setter
}
public class DestLocalTax {
private String destLocalCode;
private String destLocalTaxAmt;
}
推土機映射:
<mapping>
……….
<field map-id="map-StateTax">
<a>srcStateTaxGroup</a>
<b>stateLocalTaxGroup</b>
<a-hint>com.sample.source.SrcStateTax</a-hint>
<b-hint>com.sample.target.StateLocalTax</b-hint>
</field>
<field map-id="map-LocalTax">
<a>srcLocalTaxGroup</a>
<b>stateLocalTaxGroup.destLocalTaxGroup </b>
<a-hint>com.sample.source.SrcLocalTax</a-hint>
<b-hint>com.sample.target.DestLocalTax</b-hint>
</field>
</mapping>
<mapping map-id="map-StateTax">
<class-a>com.sample.source.SrcStateTax</class-a>
<class-b>com.sample.target.StateLocalTax</class-b>
<field>
<a>srcStateCode</a>
<b>destStateCode</b>
</field>
<field>
<a>srcStateTaxAmount</a>
<b>destStateTaxAmount</b>
</field>
</mapping>
<mapping map-id="map-1099RLocalTaxGroups">
<class-a>com.sample.source.SrcLocalTax</class-a>
<class-b>com.sample.target.DestLocalTax</class-b>
<field>
<a>srcLocalCode</a>
<b>destLocalCode</b>
</field>
<field>
<a>srcLocalTaxAmt</a>
<b>destLocalTaxAmt</b>
</field>
</mapping>
我理所當然地得到一個錯誤"No read or write method found for field (stateLocalTaxGroup.destLocalTaxGroup) in class ..
但不知道如何解決這個用例。