When I run this SQLQuery in Hibernate I aways get a count of 0. Run the same Query in SQL/Developer and it gives the correct results.
What am I doing wrong ?
Query:
Code:
count = (Long) session.createSQLQuery(""
+ "select count(*) as count "
+ " from tbl_role2 "
+ " where role_parent in (:allRoles) "
+ " start with role_name = :currRole "
+ " connect by prior role_parent = role_name ").
addScalar("count", Hibernate.LONG).
setParameter("allRoles", allRoles).
setParameter("currRole", ure.getId().getRoleName()).
uniqueResult();
Log:
2012-03-16 15:40:11,057 [http-127.0.0.1-8180-1] DEBUG - Ws: compressRoleList(): All Roles = 'Encoder', 'SAS', 'Station-Manager', 'Supervisor'
2012-03-16 15:40:11,069 [http-127.0.0.1-8180-1] DEBUG - Ws: compressRoleList(): Role='Encoder'; count=0
SQL/Dev Query
Code:
select count(*) as count
from tbl_role2
where role_parent in ('Encoder', 'SAS', 'Station-Manager', 'Supervisor')
start with role_name = 'Encoder'
connect by prior role_parent = role_name;
Result:
Count = 2
Any ideas ?