Problem:
I have a complex query using sub queries (yes I probably could do it with joins but wanted to find out why this does not work). Using simple queries against each table or limited subsets work fine. Taking the generated query and running it directly in the database also works. However, when running it in Hibernate I get no results returned. I have traced a fair percentage of the code, and I see no obvious errors.
Any pointers in where to look to debug this further would be appreciated.
TIA,
Tim
Hibernate version:
hibernate-3.1
hibernate-annotations-3.1beta7
hibernate-entitymanager-3.1beta5
Mapping Document:
Autogenerated by EntityManager based on POJO
Objects:
User [one to many to] UserCartel [many to one to] Cartel [one to many to] CartelPermission [many to one to] Permission
HQL Query:
Code:
Select p from Permission as p
where p.permissionName like :menuroot
and p in (
select cp.permission from CartelPermission as cp
where cp.cartel in
(select uc.cartel from UserCartel as uc where uc.user.userID = :userid))
Generated SQL:Code:
select
permission0_.permissionID as permissi1_3_,
permission0_.permissionName as permissi2_3_,
permission0_.pageName as pageName3_
from
Permission permission0_
where
(
permission0_.permissionName like ?
)
and (
permission0_.permissionID in (
select
cartelperm1_.permission_permissionID
from
CartelPermission cartelperm1_
where
cartelperm1_.cartel_cartelID in (
select
usercartel2_.cartel_cartelID
from
UserCartel usercartel2_
where
usercartel2_.user_userID=?
)
)
)
Name and version of the database you are using:
MySQL 5.0