-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problem
PostPosted: Mon Sep 13, 2004 11:14 am 
Newbie

Joined: Wed Jun 30, 2004 12:37 pm
Posts: 9
Hi,
I am using collection mapping with Hibernate. My problem is that Hibernate is issuing a select SQL statement for each element in the set. I did as shown in the documentation (use_outer_join=true, max_fetch_depth > 0) with no success.
Hibernate version:2.1.6

Mapping documents:
Code:
<set name="mySet" outer-join="true">
         <key column="id"/>
         <one-to-many  class="MyElement"/>
</set>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 13, 2004 11:17 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
java code?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 13, 2004 12:03 pm 
Newbie

Joined: Wed Jun 30, 2004 12:37 pm
Posts: 9
I am using Spring's HibernateDaoSupport class. My code is
Code:
getHibernateTemplate().find("from MyBean as mybean where mybean.prop=?",myprop).get(0);

As I am not using lazy initialisation, the set is fetched as soon as I fetch the object and a select statement is issued for each one of its elements. I forgot to precise a point :
The class of the elements of the set has a composite id. One of the columns composing the id is the same column I am using in the <key> of the set :
Code:
<class name="MyElement">
<composite-id>
   <key-property name="id" type="long"/>
   <key-property name="id2" type="string"/>
</composite-id>
</class>
<class name="MyBean">
      <id name="id" type="long">
         <generator class="assigned"/>
      </id>
<set name="mySet" outer-join="true">
         <key column="id"/>
         <one-to-many  class="MyElement"/>
</set>
</class>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 13, 2004 1:10 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
using hql "override" outer join parameter, just change
Code:
from MyBean as mybean where mybean.prop=?",


to

Code:
from MyBean as mybean left join fetch myBean.mySet where mybean.prop=?",

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 3:57 am 
Newbie

Joined: Wed Jun 30, 2004 12:37 pm
Posts: 9
That didn't resolve the problem, I'm afraid. Hibernate is always issuing one select per element ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 4:54 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i don't believe you, check fetch keyword in the reference guide, have you got other association behind the set?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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