-->
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: Query returning only one result?
PostPosted: Mon Aug 23, 2004 7:35 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
Hibernate version: 2.1.6

I have a query returning an array of 2 objects while I would expect it to return a 3-objects array. The query is:

select category, categoryLevel1, categoryStore1
from Catalog as catalog, CategoryStore as categoryStore1, CategoryStore as categoryStore2
inner join catalog.catalogCategories catalogCategory
inner join catalogCategory.catalogCategoryPK.category category
left outer join fetch category.categories categoryLevel1
left outer join fetch categoryLevel1.categories categoryLevel2
where catalog.catalogId = :catalogId
and categoryStore1.categoryStorePK.category.categoryId=categoryLevel1.categoryId
and categoryStore1.categoryStorePK.storeId=:storeId
and categoryStore2.categoryStorePK.category.categoryId=categoryLevel2.categoryId
and categoryStore2.categoryStorePK.storeId=:storeId
order by category.sequence

(I don't report the mapping files because they're overcomplicated and I did not write them). Is there anything obviously wrong in it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 7:47 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
I forgot to mention that the object that is not extracted is the one with alias "categoryLevel1".


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 23, 2004 5:49 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
According to your query (left join fetch), categoryLevel1 is a collection and not an entity... Therefore it cannot be part of the select clause asis.

If you need the elements, think about using the elements() keyword - if it makes sense...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 24, 2004 6:53 am 
Regular
Regular

Joined: Tue Jan 13, 2004 4:57 am
Posts: 83
bertrand wrote:
According to your query (left join fetch), categoryLevel1 is a collection and not an entity... Therefore it cannot be part of the select clause asis.

If you need the elements, think about using the elements() keyword - if it makes sense...


Ah! Thank you, this is surely the problem: I forgot that one has to use elements() for this to happen.


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