-->
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: Caching collections and NHibernateUtil.Initialize()
PostPosted: Wed May 31, 2006 11:39 am 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
Hibernate version: 1.0.2.0

Name and version of the database you are using: SQL Server 2005

I am calling NHibernateUtil.Initialize(parent.Children) where children is a many-to-one on the parent (duh).

Every time I call Initialize, nhibernate issues the query to load the child objects. How can I get it to retrieve them from the 2nd level cache? Caching works as expected in other situations so I have initialized it correctly.

The relevant mapping document looks like this:

Code:
<class name="Test.Parent" table="Parent">

   <cache usage="read-write" />

   (stuff removed)

   <bag name="Children" cascade="all" batch-size="30" lazy="true">
      <key column="parentid" />
      <one-to-many class="Test.Child,Test" />
   </bag>

</class>


Thanks for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 12:16 pm 
Expert
Expert

Joined: Fri May 13, 2005 5:56 pm
Posts: 308
Location: Santa Barbara, California, USA
try and add the cache directive to the association:

Code:
   <bag name="Children" cascade="all" batch-size="30" lazy="true">
      <cache usage="read-write" />
      <key column="parentid" />
      <one-to-many class="Test.Child,Test" />
   </bag>


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 31, 2006 2:23 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
That worked, thanks!!!!


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.