-->
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: Sequential Selects for <map> Association
PostPosted: Wed Aug 23, 2006 2:14 pm 
Newbie

Joined: Thu Jul 06, 2006 12:59 pm
Posts: 6
Location: San Francisco
I am running in to an issue involving a map association and sequential SQL selects. Using a Criteria query, I need to load a lot of fairly large business objects in a single SQL. By setting fetch mode to JOIN, I am able to do this for every joined table except for one mapped with the <map> tag. I can not seem to convince that tag to eagerly fetch the many-to-many key set. The manual’s entry on this ( http://www.hibernate.org/hib_docs/v3/reference/en/html/collections.html ) lists two XML attributes that I thought might help, “fetch” and “lazy.” However, no combination of the two seemed to effect this behavior.

The only reference to this issue that I was able to find is here: http://forums.hibernate.org/viewtopic.php?p=2297304&sid=388e7011a74f6f2160d65b71e861f83a, and that user didn’t seem to have any luck resolving the problem.

See below for details. I have attempted to reduce the complexity of the object and the associated code for the sake of simplicity. Notice that there are two select statements in the generated SQL: the test case I created has a single row in the OBJECT_COUNTRY join table, resulting in this single extra select. More rows result in more selects. Is there something I should be doing differently, or is this a bug? If the latter, could anyone suggest a work-around for this?


Hibernate version: 3.0.5

Name and version of the database you are using: Oracle 9i

Mapping documents:

Code:
<hibernate-mapping>

   <class name="db.DbDigitalObject" table="OBJECT_DEFINITION">

      …a bunch of properties

      <map name="countrySupport" table="OBJECT_COUNTRY" cascade="save-update">
         <key column="OBJECT_DEFINITION_ID" />
         <map-key-many-to-many column="COUNTRY_ID"
            class="db.DbCountry"/>
         <element column="COUNTRY_SUPPORTED" type="yes_no" />
      </map>
   </class>
</hibernate-mapping>


Criteria code:

Code:
Criteria criteria = getSession().createCriteria(DbDigitalObject.class).
   setFetchMode("countrySupport", FetchMode.JOIN);


The generated SQL (show_sql=true):

Code:
select (many properties)
from OBJECT_DEFINITION this_
   left outer join OBJECT_COUNTRY countrysup4_ on this_.OBJECT_DEFINITION_ID=countrysup4_.OBJECT_DEFINITION_ID

select dbcountry0_.COUNTRY_ID as COUNTRY1_0_,
   dbcountry0_.COUNTRY as COUNTRY10_0_
from OBJECT_COUNTRY_LOOKUP dbcountry0_
where dbcountry0_.COUNTRY_ID=?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 1:09 am 
Newbie

Joined: Wed Mar 29, 2006 8:42 pm
Posts: 7
Same problem here. I've been hoping to get around this by putting in a join to the map's key element, but I haven't got anywhere.

Something like:
setFetchMode("countrySupport.key", FetchMode.JOIN);

But clearly that's just wishful thinking.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 24, 2006 5:33 pm 
Newbie

Joined: Thu Jul 06, 2006 12:59 pm
Posts: 6
Location: San Francisco
jdwyah wrote:
Something like:
setFetchMode("countrySupport.key", FetchMode.JOIN);


Yes, that is just what I was hoping to find. Does anyone know if something like this could be accomplished? I am concerned about this going to our production-site as is. Seems like whoever added the map-key-many-to-many feature would have taken this in to consideration. I am just not sure where to look for it.


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.