-->
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: Using Hibernate Criteria to perform JOIN on a non-mapped col
PostPosted: Fri Aug 06, 2010 3:09 pm 
Newbie

Joined: Wed Jan 14, 2009 3:34 pm
Posts: 1
THere are 3 tables:

UserRole (id, name)
LoginUserRole(login_id, user_role_id)
UserRolePerm(id, user_role_id, project_id, ...)

We need to get a list of user roles for a given user, project. The SQL would be...

SELECT login_user_role.user_role_id
FROM login_user_role
JOIN user_role_permissions
ON login_user_role.user_role_id = user_role_permissions.user_role_id
WHERE login_id = 1
AND user_role_permissions.project_id = 1
ORDER BY login_user_role.user_role_id


How can this be done with Hibernate Criteria API?

It seems like there's no way to do this query since LoginUserRole and UserRolePermissions are not directly related. (They're related by user_role_id which is what the JOIN is occurring on with SQL query)

Thx,
tshah


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.