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.  [ 3 posts ] 
Author Message
 Post subject: SQL Query Returns Result, But Empty List Returned [JSR220]
PostPosted: Thu Dec 15, 2005 11:54 pm 
Newbie

Joined: Thu Dec 15, 2005 11:24 pm
Posts: 5
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 16, 2005 9:55 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
you have a problem with parameters, probably (menuroot and userid)
i can't know abotu mysql, but problem can be encoding (differen in my sql and java) or
parameter type ...
see parameters in debug and check encoding in mysql


Top
 Profile  
 
 Post subject: Tested With and Without Parameters.
PostPosted: Fri Dec 16, 2005 2:49 pm 
Newbie

Joined: Thu Dec 15, 2005 11:24 pm
Posts: 5
snpesnpe,
I tried with params and without. No change in behaviuor. Further, I have followed the strack trace all the way down and and the params are set correctly.

Tim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.