I have this scenario: 4 classes {AC, BC, CC, DC} and 3 tables {BT, CT, DT}.
Classes:
public abstract class AC {}
public class BC extends AC { }
public class CC extends AC {
private BC bc;
}
public class DC {
private AC ac;
}
Tables:
CT foreign key to BT
DT foreign key to BT
I mapped :
<class name="BC" table="BT"/>
<class name="CC" table="CT">
<many-to-one name="bc" class="BC" column="id_BC" />
</class>
My problem is the class DC. When there arent a record in CT that points to a record in BT, then the property ac in DC class point to an instance of BC. However, when there are a record in CT that point to the record in BT, then ac points to an instance of CC.
I think must use <any>, because the polymorphism. But then i need a field in DT for this. The decision of why type of instance will point "ac" I need use a formula, but there isnt possible in <any>
How can I resolve this?
Thanks
Adilson
|