I'm having trouble with a resultmapping, using the latest beta of the
mapper.
The problem occurs when a resultMapping only contains properties with
select attributes (no direct result properties). In the example below,
I'm trying to map a ReferencePeople object to my Customer object.
ReferencePeople is a simple class that contains a customer's reference
people at a company and some minimal logic. As such, it contains no
properties other than other mapped objects (such as Salesman). When
doing the mapping below, despite creating ReferencePeople abject and
adding a salesman to it, Ibatis injects null into the ReferencePeople
property of Customer. However, if I add any direct property to
ReferencePeople, such as copying the Customer's version property in
there, then Ibatis properly injects a ReferencePeople object into Customer.
<resultMap id="Customer" class="Customer">
<result property="CustomerID" column="CustomerID"/>
<result property="ReferencePeople"
resultMapping="Customer.ReferencePeopleResult"/>
<result property="Version" column ="Version"/>
</resultMap>
<resultMap id="ReferencePeopleResult" class="ReferencePeople">
<result property="PreferredSalesman" column="PreferredSalesman"
select="GetSalesmanByCustomerID"/>
<!-- If I add a random property from Customer to ReferencePeople, so
that it has a direct property, then everything works fine -->
<!--<result property="Version" column ="Version"/>-->
</resultMap>
class customer
properties: CustomerID: long, ReferencePeople: ReferencePeople,
Version: long
class ReferencePeople
properties: PreferredSalesman: Salesman, Version: long (version was
only added in debugging and does not belong in ReferencePeople)
DB:
Customer and ReferencePeople information are both stored in the
Customer Table, Salesman infromation is in its own table.
Cheers,
Peter