-->
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: Lazy collection loading disregarded - why?
PostPosted: Wed Feb 25, 2004 1:24 pm 
Newbie

Joined: Wed Feb 25, 2004 12:27 pm
Posts: 2
We're using hibernate 2.0.1 with Oracle 9. There's a parent-child relation between Content and ContentLink - a Content is mapped to have a lazy list of ContentLinks. (I am attaching the mapping below.)

The problem is that the list is loaded every time as soon as the parent object is loaded via Session.load().

I thought the problem was with ContentLink that has a composite primary key (content_id, sequence_num), and the same sequence_num is used for List mapping. I have tried two things - changing List mapping to Set, and adding a synthetic primary key to ContentLink. Neither approach helped.

Now I am thinkging about trying the latest version of hibernate, but that is going to involve a lot of changes in our project, so I decided to check with you guys.

Also, I do have the full debug log, and it doesn't mention any "lazy" collections, just goes and loads everything. It's a long file, so I didn't attach it.

Thanks for your time,
Alex

Code:
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="com.amg.condenet.style.content.domain.Content" table="CONTENT">

  <id name="contentId" type="string" column="content_id" length="255">
   <generator class="assigned"/>
  </id>

  <property name="body"        column="body"         type="com.amg.condenet.data.StringClobType" not-null="true"/>
  <property name="title"       column="title"        type="string"    not-null="true"  length="512"/>
  <property name="byline"      column="byline"       type="string"    not-null="false" length="512"/>
  <property name="subtitle"    column="subtitle"     type="string"    not-null="false" length="512"/>
  <property name="location"    column="location"     type="string"    not-null="false" length="512"/>
  <property name="overrideURL" column="override_url" type="string"    not-null="false" length="512"/>
  <property name="displayDate" column="display_date" type="timestamp" not-null="true"/>
  <property name="expireDate"  column="expire_date"  type="timestamp" not-null="false"/>
  <property name="liveDate"    column="live_date"    type="timestamp" not-null="false"/>
  <property name="archived"    column="is_archived"  type="yes_no"    not-null="true"/>

  <many-to-one name="template"
   column="template_id"
   class="com.amg.condenet.style.content.domain.Template"
   not-null="true"/>

  <many-to-one name="contentType"
   column="content_type_id"
   class="com.amg.condenet.style.content.domain.ContentType"
   not-null="true"/>

  <many-to-one name="sourceType"
   column="source_type_id"
   class="com.amg.condenet.style.content.domain.SourceType"
   not-null="true"/>

  <list name="contentLinks" lazy="true" inverse="true" cascade="all">
    <key column="content_id"/>
    <index column="sequence_num"/>
   <one-to-many class="com.amg.condenet.style.content.domain.ContentLink"/>
  </list>
 
</class>
</hibernate-mapping>

<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>

<!-- com.amg.condenet.style.content.domain.ContentLink root -->

<class name="com.amg.condenet.style.content.domain.ContentLink" table="CONTENT_LINK">

   <composite-id>
      <key-many-to-one name="content" column="content_id" />
      <key-property name="sequenceNum" column="sequence_num"   type="integer"/>
   </composite-id>

   <many-to-one name="contentLinkType" column="content_link_type_id"/>
   <many-to-one name="slideshow"       column="slideshow_id"/>
   <many-to-one name="photo"           column="photo_id"/>

   <property name="text" column="text" type="string"    not-null="false"  length="255"/>
   <property name="link" column="link" type="string"    not-null="false"  length="255"/>

</class>
</hibernate-mapping>



Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 25, 2004 2:17 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
remove everything but the offending one-to-many, do a simple load and show the log. It'll help us and you.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 02, 2004 12:07 pm 
Newbie

Joined: Wed Feb 25, 2004 12:27 pm
Posts: 2
Thanks for a prompt responce. Unfortunately, I had to go to other more critical bugs, but I will definitely revisit this question in the near future.

Alex


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.