-->
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.  [ 2 posts ] 
Author Message
 Post subject: second level cache and associations
PostPosted: Tue Dec 05, 2006 1:35 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
I am trying to understand the behavior of associations when second level cache is enabled for an entity. I looked into documentation and it mostly talks about caching simple entities and I couldn't find an answer for my question.

Our application uses lot of associations as you can see in the following simple case:

Basically, my question is when I enable caching (second level) for say, Product_category, will it automatically enable caching for its products association and its many-to-one assocation?

If this is already documented somewhere, would you please direct me?

Thanks!
Madhan.



<hibernate-mapping>
<class name="ProductCategory" table="PRODUCT_CATEGORY" schema="DEALER">
<id name="productCategoryId" type="big_decimal">
<column name="PRODUCT_CATEGORY_ID" precision="22" scale="0" />
<generator class="assigned" />
</id>
<many-to-one name="pageSetup" class="PageSetup" fetch="select" lazy="false">
<column name="PAGE_SETUP_ID" precision="22" scale="0" />
</many-to-one>
<property name="productCategoryName" type="string">
<column name="PRODUCT_CATEGORY_NAME" length="512" not-null="true" />
</property>
<set name="products" inverse="true" lazy="true">
<key>
<column name="PRODUCT_CATEGORY_ID" precision="22" scale="0" />
</key>
<one-to-many class="Product"/>
</set>
</class>
</hibernate-mapping>

===========

I am using hibernate 3.1


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 7:06 pm 
Newbie

Joined: Tue Dec 05, 2006 6:15 pm
Posts: 4
Location: London, England
Quote:
will it automatically enable caching for its products association


You need to configure a separate cache for the association. I've only done this using Spring but as the Spring Javadoc points out - http://static.springframework.org/spring/docs/1.2.x/api/org/springframework/orm/hibernate3/LocalSessionFactoryBean.html#setCollectionCacheStrategies(java.util.Properties) - this is equivalent to the collection-cache element in the Hibernate XML Configuration File (See http://www.hibernate.org/hib_docs/v3/reference/en/html/session-configuration.html#configuration-xmlconfig).

Presumably you can also just specify a <cache> element in the Set configuration, per Section 19.21 in the Hibernate documentation (http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-cache) although I haven't tried it.

Hope this helps.

John

_________________
If you want IT, dowNinja IT.


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