ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikael Andersson" <mail.mi...@gmail.com>
Subject Polymorphism question
Date Fri, 23 Mar 2007 18:49:08 GMT
I have a polymorphism problem which I'm not sure is solvable by a pure
iBATIS solution.

I have a fixed database model which represents a hierarchy(very simplified):

| id |col1 | col2 | type |

| id |colX | colY |

| id |colZ | colW |

Which has an obvious object hierarchy, and "type" contains a either 'A' or
'B' indicating which child table should be used.

The id of the base and the child is the same, and the same id can not exists
in the two child tables.

I have found information which shows how the <discriminator> element can be
used with a column indicating the object to create. Which solves half of my

The other half is something which I don't think is solvable, but figured I'd
ask just in case it is.
I need the select join statement to be modified depending on the value of
the "type" column, which table to join with. I have no idea how to do this
in iBATIS, and am currently leaning towards implementing this in Java logic
(first get the type from the base table and then execute the correct select

Any help appreciated,

View raw message