I'm having a problem determining the way I need to set up my annotations for my mappings for the following.
I have 4 domain objects (User, GroupMembers, BusinessCaseGroup, and BusinessCase).
User has a PK of username and other fields that don't pertain to this. GroupMembers has a PK of group_members_id and other fields username and group_id BusinessCaseGroup has a PK of businesscase_group_id and other fields businesscase_id and group_id BusinessCase has a PK of businesscase_id and other fields name and 2 Collections (Set) that each have a one-to-many relationship.
When I get a the User object for a specific username, I need to get the BusinessCase's assigned to the group that the user is assigned to. I know there is a many-to-many relationship and I've tried to use NamedNativeQuery with the sql (see below), but I've had no luck implementing this. select bc.business_case_id as id, bc.abbreviation as abbreviation, bc.name as name from users u, group_members gm, business_case_group bcg, business_case bc where u.username = gm.username and gm.group_id = bcg.group_id and bcg.business_case_id = bc.business_case_id and u.username = ?
I've been pulling my hair out for 2 days trying different things, but I've basically gotten nowhere. I'd like to start fresh.
Can anyone make a suggestion on how to implement this structure? When using the NamedNativeQuery, I wasn't expecting to need a cross-reference table. Am I correct in this thought?
Thanks
|