Having more mapped fields than query returns

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

Having more mapped fields than query returns

Nicolai Willems
Hi there

Is the below scenario possible? If not why? if yes - is there any modifications needed to the way I do it?
I have a scenario where I would like to have a single ResutMap for an association existing in three other different ResultMaps.
ala this:
<resultMap id="assoc1Map" type="com.john.doe.fancyType">
    <id column="param1" property="param1" javaType="Integer" />
    <association property="assoc" javaType="AssociationType" resultMap="assocMap"></association>
</resultMap>
<resultMap id="assoc2Map" type="com.john.doe.fancyType">
    <id column="param2" property="param1" javaType="Integer" />
    <association property="assoc" javaType="AssociationType" resultMap="assocMap"></association>
</resultMap>
<ResultMap id="assocMap" type="AssociationType">
    <id column="someID" property="id" javaType="Integer" />
    <result column="SomeTotal" property="total" />
    <result column="SomeAverage" property="average" />
    <result column="AnotherTotal" property="totalOther" />
    <result column="AnotherAverage" property="averageOther" />
</ResultMap>

Where one query would use assoc1Map and only fill SomeTotal and SomeAverage in assocMap
and another query would fill the Another-fields.

Thanks in advance
Regards
Nicolai