-->
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: Collection Mapping: Selecting the Appropriate Subtype
PostPosted: Tue Feb 22, 2005 11:43 am 
Regular
Regular

Joined: Wed Nov 17, 2004 11:49 am
Posts: 65
Location: Pittsburgh
Hibernate version:

2.1.4

I have several situations where I use the table-per-class-heirarchy mapping. I have found that when I map collections to a specific subtype in this heirarchy it is necessary to provide a where clause to the discriminator column. This is fine for one-to-many mappings, because the discriminator column is on the child table. I have had a problem with many-to-many mappings, however, as I do not know the table alias to use in the where clause, and the discriminator column is not on the join table. I have worked around this problem as well by creating a distinct join table for each type mapping. I am not fully satisfied with this solution, however.

To give a concrete example, I have a stakeholders table to which I map two types of StakeHolders, BoardMember and Employee. I also have a Project object that maps collections of both types.


project.getEmployees() : Collection of Employees;
project.getBoardMembers() : Collection of BoardMembers;

employee.getProjects() : Collection;

boardMember.getProjects() : Collection;

The tables involved would be project, stakeholder (with a disciminator column) and project_stakeholder_lnk

My question has two parts, then

1. Why is specifying the class attribute not sufficient to filter the results to include only the requested subtype?

2. Is it possible to specify a column on the child table (in the example stakeholder) in a where attribute for a many to many mapping?


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.