-->
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 associations to interface hierarchies
PostPosted: Mon Nov 24, 2008 11:27 pm 
Newbie

Joined: Sun Nov 16, 2008 7:01 am
Posts: 2
Hi guys,

how would you map the following object diagram (with the sensible restriction that User, Product and Stuff go to different tables).

Code:
       ICommentable  IRateable
       ^        ^    ^        ^
       |         \  /         |
       |          \/          |
   User       Product      Stuff

Comment *----------- ICommentable

Rating *---------------- IRateable


Some possibilities that come to my mind:

1) Mapping the many-to-one of Comment and Rating with <any>. (table per concrete class with implicit polymorphism)

2) Using table per concrete class with unions. But I can't figure out any way to avoid duplicated mappings for classes that take part of multiple (interface) hierarchies (Product in the example which is both a ICommentable and a IRateable). And AFAIK these duplicated mappings are forbidden. I could compromise my design and make all of User, Product and Stuff extend some AbstractCommentableRateable class. Of course, besides the crippled design, the unions will then include a third unneeded table for both associations (Stuff for the Commentable one, User for the Rateable one).

Any better idea?

Best regards
-Carlos


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.