-->
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: Bags, with an index from a row?
PostPosted: Fri Jan 25, 2008 8:18 am 
Newbie

Joined: Fri Jan 25, 2008 8:00 am
Posts: 11
Hello all, I hope that this question doesn't get asked too often (I've put a to the point question at the end of the post).
Unfortunately I couldn't find much on google, but maybe I don't know the technical name for exactly what I'm trying to do. (So if someone could even tell me that, I could google more!)

Hibernate version:
3.2.5.ga

Tables
Code:
Users
   Id
   Username

Projects
   Id
   Code
   Description

ProjectAssignments
   Id
   UserId
   ProjectId
   ProjectRoleId

ProjectRoles
   Id
   RoleName


Background:
A user can be assigned to projects via the ProjectAssignments table.

There are multiple roles, such as "Supervisor", "Reviewer".

One user can be assigned to many different projects as the same role, i.e, they can supervise many projects.
Furthermore, each project can have many users assigned to it, i.e, the project will have supervisors and reviewers.

Question:
Essentially I want to be able to do a Users.getSupervisedProjects();

I therefore need an underlaying collection that is mapped

RoleName => Project.

This is well and simple with a <map> as I can use the <map key column="ProjectRoleId">, however as a map could only map one Supervisor => Project association, it is no good (as a user may have may Supervisor roles).

I therefore need to use a <bag>, but the documentation says that a <bag> can't set up a key like the Map does.

Then there is IDBag, but the documentation says that the index generator may not pull info from the table like the <map key> can.

To the point question
Am I forced essentially to hold a set of ProjectAssignment classes in a set, instead of making the ProjectRoleId an index on my collection.

Thank you very much for reading, and thanks in advance for any replies.


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.