-->
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: inner join fetch - multiple instances
PostPosted: Thu Jun 10, 2004 2:10 pm 
Newbie

Joined: Thu Aug 28, 2003 11:49 am
Posts: 15
Location: Calgary, Alberta, Canada
- Hibernate 2.1.4 & 2.1.2
- MS SQL Server 2000
- Product -> ProductDescriptions (1-m)
Code:
<map
                name="descriptions"
                table="product_detail"
                lazy="true"
                sort="unsorted"
                inverse="false"
                cascade="all">

            <key column="product_id"></key>

            <index column="locale"
                    type="string" />

            <one-to-many
                    class="com.fgl.fwp.model.products.ProductDescription" />
        </map>

- I'm trying to fetch products with the descriptions already instantiated using:

Code:
select p from Product as p inner join fetch p.descriptions


each product has two descriptions so the List returned from the query contains the same product instance twice.

I can take the list and put into a set to remove the duplicates, but I'm wondering if there is a way for me to get my intended results without having to resort to this.

thanks,
Darcy.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2004 11:41 am 
Newbie

Joined: Fri Jun 18, 2004 11:29 am
Posts: 3
I am having exactly the same problem.

According to the documention,

.. a "fetch" join allows associations or collections of values to be initialized along with their parent objects, using a single select. This is particularly useful in the case of a collection. It effectively overrides the outer join and lazy declarations of the mapping file for associations and collections.

ref:
11.3. Associations and joins
http://www.hibernate.org/hib_docs/refer ... ryhql.html


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 18, 2004 2:07 pm 
Newbie

Joined: Fri Jun 18, 2004 11:29 am
Posts: 3
Finally found the answer. See FAQ

http://www.hibernate.org/74.html#A7

Suggestion - add this to the Hibernate "documentation" :-(


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