-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Polymorphic Relationship
PostPosted: Fri Dec 02, 2005 1:48 pm 
Newbie

Joined: Fri Dec 02, 2005 1:30 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.