Hi all,
I am writing an interface to a database and need some help with a nested query I have the following tables
Fguser
Fguserrole
Role
layerrole
layer
sessiontoken
these are mapped as follows :
layer -one-to-many-
layerrole-many-to-one-
role-one-to-many-
fguserrole-many-to-one-
fguser-one-to-many-
sessiontoken
I have the sessiontokenId and I want to get the layers for the user, In SQL I would do this :
Code:
SELECT DISTINCT l.*
FROM layer_role lr, layer l
WHERE lr.layer_id = l.layer_id
AND lr.role_id IN ( SELECT fr.role_id
FROM fguser_role fr, sessiontoken st
WHERE fr.fguser_id = st.fguser_id
AND st.session_id = '?')
I am a little stuck as to how to implement this in Hibernate. We are currently using the DAO DTO model.
Any help appreciated
Connie