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..
|