ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Persitence Interface
Date Sun, 29 Oct 2006 21:21:20 GMT
Look into using a discriminator - they work great for what you are describing.

Here is a realllly terse example:

<discriminator javaType="string" column="type">
    <subMap value="Cash" resultMap="rmCash" />
    <subMap value="Pledge" resultMap="rmPledge" />
    <subMap value="PayPalDirPay" resultMap="rmPayPalDirPay" />
    <subMap value="PayPalExpChkout" resultMap="rmPayPalExpChkout" />
</discriminator>

It looks at the type column, and based on the value, uses a different
result map.

Neat, huh?

Larry


On 10/29/06, Andreas Prudzilko <aprudzil@welho.com> wrote:
> Hello,
>
> I have one interface Template and several Subclasses for it,
> AbstractTemplate, PageTemplate and so on.
> They are all persisted in the same table though, distinguished by a
> column called "type".
>
> I was wondering how I can tell ibatis to create instances of the right
> classes based on the column value.
>
> My guess was creating a resultObjectFactory. But I can't find any good
> documentation on how to do this.
>
> Any ideas?
>
> - Andreas
>

Mime
View raw message