-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with HQL inner join
PostPosted: Thu Mar 13, 2008 8:22 am 
Beginner
Beginner

Joined: Tue Feb 26, 2008 2:04 pm
Posts: 28
Location: UK
Hi,

Does anyone know why the following hql results in an inner join instead of a left one :

***from User as user left join fetch user.tasksWorkingOn as task where user.id= :id and task.deleted=true***

...also any other syntax other than ***left join*** fails. So, if you try ***left outer join*** HQL fails...

...also Criteria has a problem with Boolean expressions :

userCriteria.createCriteria("tasksWorkingOn").add(Expression.eq("deleted",new Boolean(true))); where ***deleted*** is declared as boolean.

...bottom line: does anyone know how a left join is performed in HQL??


Thanks a lot,


mosa


Top
 Profile  
 
 Post subject: Re: Problem with HQL inner join
PostPosted: Thu Mar 13, 2008 11:12 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
What is the exception when left outer join fails?



Farzad-


Top
 Profile  
 
 Post subject: Re: Problem with HQL inner join
PostPosted: Thu Mar 13, 2008 12:14 pm 
Beginner
Beginner

Joined: Tue Feb 26, 2008 2:04 pm
Posts: 28
Location: UK
farzad wrote:
What is the exception when left outer join fails?



Farzad-


it seems that the hql parser needed a select clause in order to parse correctly the query string...so maybe this was my bad :)

However, the issue with the Boolean's still holds. Specifically, the ***task.deleted=true*** part is not included at all in the result as my users are not being filtered at all by their deleted tasks. It seems to work fine with fields other than Boolean (e.g. int’s)

Do you know if there is an issue with a Boolean in the where clause ??


Thanks very much


mosa


Top
 Profile  
 
 Post subject: Re: Problem with HQL inner join
PostPosted: Thu Mar 13, 2008 12:20 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
The only thing I can recall is that usually the dialect class replaces booleans with whatever is appropriate in the host database. However, this is not the case in Criteria queries. You could do the same thing in HQL and see if that makes things different.



Farzad-


Top
 Profile  
 
 Post subject: Re: Problem with HQL inner join
PostPosted: Thu Mar 13, 2008 12:42 pm 
Beginner
Beginner

Joined: Tue Feb 26, 2008 2:04 pm
Posts: 28
Location: UK
farzad wrote:
The only thing I can recall is that usually the dialect class replaces booleans with whatever is appropriate in the host database. However, this is not the case in Criteria queries. You could do the same thing in HQL and see if that makes things different.



Farzad-


I tried doing that earlier by setting a 1 instead of true to the hql as Hibernate has implemented the boolean as a tinyInt in my db (a MySql by the way)..unfortunately that didn’t work.

Anyway, I had to fix that bug a bit manually by iterating/filtering through the collection.


thank you very much,


mosa


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.