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
Hi
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):

BaseTable
| id |col1 | col2 | type |

ChildTable1
| id |colX | colY |

ChildTable2
| 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
problem.

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
statement).

Any help appreciated,
 Mike

Mime
View raw message