-->
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.  [ 2 posts ] 
Author Message
 Post subject: Polymorphic components? Is it the way to solve this problem?
PostPosted: Fri Nov 12, 2004 7:32 pm 
Newbie

Joined: Tue Sep 30, 2003 10:08 am
Posts: 7
Location: Turkey
Hello, I got a question about a case I meet very frequently and do not know how to map to my db... Can someone help me on this?

Suppose that I have a class StudentGroup to which students are registered... A student group might have lectures at weekends or weekdays, and for each of these, they might have lectures at morning or at noon, so I endup with two abstract classes; WeekDayGroupType and DayTimeGroupType... And according to these rules, different policies might be applied to these groups... Besides, these group types, I mean weekend and weekday groups and morning or noon groups might have some properties special to that group besides several strategies regarding to implementation..So I end up with four subclasses in my model; WeekdayGroupType, WeekendGroupType - MorningGroupType, NoonGroupType, which extend from two main abstract classes or interfaces; WeekDayGroupType and DayTimeGroupType... However, the GroupTypes does not seem as reference types to me, because they do not have different properties in each instance of StudentGroup... That tells me, GroupTypes must be polymorphic components, instead of one-to-one polymorphic entity types to StudentGroup so I can use only a single table for the whole ... Am I right? How can I map such a polymorphic value type in Hibernate?... I could not find a direct way of it, maybe a CompositeUserType might help I think, but I am not sure...What do you suggest? Thanks for any suggestions in advance..


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 8:08 pm 
Newbie

Joined: Tue Sep 30, 2003 10:08 am
Posts: 7
Location: Turkey
Well, thinking a bit more about on the subject, maybe a different approach can be defining the WeekDayGroupType and DayTimeGroupType classes as "real" knowledge level classes and just reverse the assosiations... I mean a WeekDayGroupType might be a reference type which holds a collection of StudentGroups, and the same might be done with DayTimeGroupType object as well... What do you think? Can that be a better approach?


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

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.