The other way to do this is to use a discriminator result map. All of the
objects implement ILabelled, so that can be the returned type from the
resultmap. You can then either UNION or JOIN somehow all 3 SQL statements
into a single call (also better for performance usually...not always).
For any fields that don't exist, just return null or a fixed value in the
SELECT clause, including the type field for the discriminator.
SELECT "Company" as type, company_name, NULL as event_name, NULL as title
...
UNION
SELECT "Event" as type, NULL as company_name, event_name, NULL as title
...
UNION
SELECT "Article" as type, NULL as company_name, NULL as event_name, title
...
<resultMap id="ILabelledResults" class="ILabelled">
<!-- ...common fields go here ... -->
<discriminator column="type" javaType="int">
<subMap value="Company" resultMap="CompanyResult"/>
<subMap value="Event" resultMap="EventResult"/>
<subMap value="Article" resultMap="ArticleResult"/>
</discriminator>
</resultMap>
Something like that.
Cheers,
Clinton
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Larry Meadors
Sent: August-22-07 8:19 AM
To: [email protected]
Subject: Re: appending to collection properties
Have iBATIS populate 3 lists in 3 different properties, then create a
getter that merges them into one. Simpler is better. :-)
Larry
On 8/22/07, Ole Trenner <[EMAIL PROTECTED]> wrote:
> Niels Beekman wrote:
> > Maybe
> > http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+r
> > euse+SQL-fragments helps...
>
> Thanks again for your help.
>
> Maybe I didn't describe my problem correctly.
>
> The three subselects do query three quite different tables, thus needing
> different resultMap definitions to get correctly mapped to objects.
>
> My parent object "Article" stores them in a typed List only being able
> to access them through their interface, but internally they actually
> need to be instances of their concrete classes.
>
> What I've currently done is add some "dummy" setters to my Article
> object that just appends to the actual children list and then specify
> these dummy properties for the subselects.
>
> However, somehow the described behaviour contradicts the documentation,
> and since I'd very much prefer the documented behaviour, I'd like to
> know why :)
>
> Cheers.
> Ole.
>
>