-->
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.  [ 4 posts ] 
Author Message
 Post subject: SQL Query Returns Result, But Empty List Returned
PostPosted: Sat Dec 17, 2005 12:10 pm 
Newbie

Joined: Thu Dec 15, 2005 11:24 pm
Posts: 5
Sorry for cross posting (I posted this incorrectly in the User forum).

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 object or limited subsets work fine. Taking the generated query and running it directly in the database also works. However, when running it in the Hibernate Entity Manager I get no results returned. I have traced a fair percentage of the code, and I see no obvious errors; I have also eliminated the params and hard coded values in the select to no avail. If desired, I can either post or email a sample project.
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 documents:
Autogenerated by EntityManager based on POJO

Name and version of the database you are using:
MySQL 5.0

Object Structure
(Since group is a reserved word, I used cartel :-)

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))


The generated SQL (show_sql=true):
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=?
                    )
                )
        )


Top
 Profile  
 
 Post subject: Answer (Operator Error)
PostPosted: Sat Dec 17, 2005 3:45 pm 
Newbie

Joined: Thu Dec 15, 2005 11:24 pm
Posts: 5
Tracing the code, I found my error. I was trying to set the param as a primitive value, and Hibernate required that it be a Class representation.

Tim


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 7:11 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
hug! bad autoboxing

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Yes, Autoboxing was the root problem.
PostPosted: Mon Dec 19, 2005 8:43 am 
Newbie

Joined: Thu Dec 15, 2005 11:24 pm
Posts: 5
Sometime I think we move two steps backward in an attempt to move one step forward. I believe this change will break many applications, it has already busted two applications I am aware of, plus it caught me in my new development. (We make extensive passing of primitives for performance, and autoboxing, as I understand it, will kill us by instantiating then dropping wrapper classes.)


Tim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.