-->
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: Mapping problem
PostPosted: Tue May 25, 2010 1:35 pm 
Newbie

Joined: Fri May 25, 2007 3:58 pm
Posts: 10
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


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.