-->
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.  [ 2 posts ] 
Author Message
 Post subject: HQL : .class with outer join
PostPosted: Tue May 15, 2007 10:28 am 
Newbie

Joined: Tue May 15, 2007 10:10 am
Posts: 8
I have some trouble with the .class keywork.

1 - The following request works fine :
[HQL]
Code:
select item from Item item where item.class = CD and item.Tracks.size > 2


[Generated SQL]
Code:
select item0_.ID as ID0_,
       item0_.NAME as NAME0_,
       item0_.STATUS as STATUS0_,
       item0_.TYPE as TYPE0_,
       item0_.CA TEGORYID as CATEGORYID0_,
       item0_.BUYERID as BUYERID0_,
       item0_2_.SUMMARY as SUMMARY3_,
       decode(item0_.ID, item0_1_.ID, 1, item0_2_.ID, 2, 0) as clazz_
  from ITEMS item0_, CDS item0_1_, BOOKS item0_2_
where item0_.ID = item0_1_.ID(+)
   and item0_. ID = item0_2_.ID(+)
   and ((decode(item0_.ID, item0_1_.ID, 1, item0_2_.ID, 2, 0) = 1) and
       ((select count(*)
            from TRACKS tracks 1_
           where item0_.ID = tracks1_.CDID) > 2))


2 - The following request doesn't work fine :
[HQL]
Code:
select user from User user left outer join user.Bids bid where bid.Item.class = Book and length(bid.Item.Summary) < 50


[Generated SQL]
Code:
select user0_.ID        as ID6_,
       user0_.FIRSTNAME as FIRSTNAME6_,
       user0_.LASTNAME  as LASTNAME6_,
       user0_.AGE       as AGE6_,
       user0_.STREET    as STREET6_,
       user0_.CITY      as CITY6_,
       user0_.ZIPCODE   as ZIPCODE6_,
       user0_.COUNTRY   as COUNTRY6_,
       user0_.USERLEVEL as USERLEVEL6_,
       user0_.TYPE      as TYPE
  from USERS user0_, BIDS bids1_, ITEMS item2_
where user0_.ID = bids1_.USERID(+)
   and ((decode(item2_.ID, item2_1_.ID, 1, item2_2_.ID, 2, 0) = 2 and
       bids1_.ITEMID = item2_.ID) and
       (length(item2_2_.SUMMARY) < 50 and bids1_.ITEMID = item2_.ID))


Does anyone know how to solve this ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 15, 2007 10:40 am 
Newbie

Joined: Tue May 15, 2007 10:10 am
Posts: 8
I found a solution, but it isn't really OO :

Code:
select user from User user left outer join user.Bids bid, Book book where bid.Item = book and length(book.Summary) < 50


I wonder why the first one was not working.


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