I was looking for a way to map collections of derived types where the foreign key for the collection resides in the PK of the base.
The following thread describes the situation. I'll quotes pieces here.
http://forum.hibernate.org/viewtopic.php?t=941990&highlight=joinedsubclass
dtabuenc said:
Quote:
I have ran into this problem as well. The problem is that there is no way to tell hibernate that the foreign key is in the base class. I haven't found a way to do this. Hibernate seems to ignore the inheritance relationship and blindly just always asumes that the foreign key is in the derived class' table.
I also want to know if this is considered a bug and if there is a good workaround to make collections of derived types using joined-subclass strategy.
Gavin goes on to say:
Quote:
Anyway, what you are trying to do seems utterly broken from a data modelling standpoint. My recommendation to people who want to do stuff like this is always: go buy a book and learn more about data modelling.
I don't understand how this is broken from a data modelling standpoint. Looks to be a standard Superclass/subclass situation.
Is the only work around to have a map collection of the base type then create a wrapper that iterates through the base collection then casts each one to the derived type?
Sorry, I am having trouble figuring this out. I will have to ditch Hibernate if i can't do this. Our database does this kind of superclass/subclass thing all over the place.
Christian