-->
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 association with derived class
PostPosted: Wed Jul 30, 2008 4:35 pm 
Newbie

Joined: Mon Jun 18, 2007 2:08 pm
Posts: 10
Folks:

Is that possible to have polymorphic association in which a derived class has a different key type?

Example: (from http://www.developer.com/open/article.p ... _3559931_5)

Listing 7. Table-per-subclass mapping

<class name="Event"table="events">
<id name="event_id"type="long">
<generator class="native"/>
</id>
<joined-subclass name="ConferenceEvent"table="conf_events">
<key column="event_id"/>
...
</joined-subclass>
<joined-subclass name="NetworkingEvent"table="net_events">
<key column="event_id"/>
...
</joined-subclass>
</class>


Now, let's say I need to add a class, say CompositeEvent, in which the primary key is actually a composite key, say String, int, String.

Is there a way to map it using polymorphic association? If so, how? if not so, what is the approach one takes in this case?

I am thinking in terms of having that table map to a event_id; however, have some type of interceptor to tell hybernate to "translate" the single PK on the event table to a 3 piece primary key. Would interceptors be a good way to do that?


Thank you in advance & Regrads,

Harringf


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.