I am trying to mimic a eager fetch for a specific situation only.I use spring-data-jpa with hibernate 4.1 as implementation. i have User, Role and Right. Role and User have many-to-many with additional field thus mapped as an Entity RoleUser. Role and Right also are in many-to-many mapped as an Entity RoleRight.
I would like to load all right and role for a user into the Authorization mechanism of the application when needed. this query below is giving illegal attempt to dereference collection
List<Role> roles = (List<Role>)em.createQuery("select r from RoleImpl r JOIN FETCH r.roleRightMap rrm JOIN FETCH rrm.right ur WHERE r.userRoleMap.user.ID=:id ")
.setParameter("id", ID).getResultList();
How can it be rewritten to load the role and its mapping thanks.