ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Trenner <ole.tren...@gmx.de>
Subject Re: Splitting one table row into a master object with sub-objects
Date Thu, 09 Aug 2007 21:06:15 GMT
Hi,

Amin Ahmad wrote:
> Thanks very much for your help, Ole. This solved my problems, though I
> would like to add a few of my own observations:
> 
> (1) Is it necessary to create the composite result map
> (id="CompositeTopResult")? I added the lines below:
>       <result property="subClassProperty1" resultMap="SubResult1"/>
>       <result property="subClassProperty2" resultMap="SubResult2"/>
>     Directly into the "TopResult" resultMap and had no problems.


Both approaches should be equivalent. I simply prefer the one with the
extended "base" resultMap because we often start with abator generated
"flat" result maps. Since we don't want to change generated code/config,
we implement our own functionality by extending those artifacts.


> (2) The resultMap/result syntax diagram on page 31 of the manual seems
> to suggest that column is a mandatory attribute of result when in fact
> it is not. This contributed to my initial confusion.


The pdf doc says on page 35:

"In iBATIS versions 2.2.0 and above, you can also reuse a result map in
a 1:1 query instead of repeating the columns."


> (3) One oddity I encountered was that the resultMap reference needs to
> be fully qualified with the name-space in front. I don't know if this is
> a bug of feature, but simply using resultMap="Subresult1" resulted in an
> error saying the resultMap is not defined. When I qualified it with the
> namespace, everything worked, even though both result maps (TopResult
> and SubResult1) are defined in the same namespace.


I'm not quite sure, but you should be able to configure the behaviour
with the useStatementNamespaces attribute of the settings element in
your sqlMapConfig:


<sqlMapConfig>
    <settings useStatementNamespaces="false"/>
	...
</sqlMapConfig>


> Thanks again for you help.
> amin

Best regards,
Ole.

Mime
View raw message