-->
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.  [ 4 posts ] 
Author Message
 Post subject: second level cache and entity inheritance
PostPosted: Wed Aug 04, 2010 3:56 pm 
Newbie

Joined: Wed Aug 04, 2010 1:25 pm
Posts: 2
Does Hibernate use the cache for a parent entity if there is no explicit cache for a child entity of the parent? For example, say I have the following.

Code:
package test;

@Entity
public class Parent {
}

@Entity
public class Child extends Parent {
}

<hibernate-configuration>
    <session-factory>
    ...
        <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
        <property name="hibernate.cache.use_second_level_cache">false</property>
    ...
        <!-- Hibernate Secondary Cache -->
        <class-cache class="test.Parent" usage="read-write"/>
...


Will Hibernate use the test.Parent cache to cache instances of test.Child, or must I explicitly enumerate all the caches for subclasses in the hierarchy? Note the use_second_level_cache property is false.

I am using Hibernate 3.2 with Ehcache 1.3.

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: second level cache and entity inheritance
PostPosted: Wed Aug 04, 2010 11:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Not really sure what you are getting at here. You have told Hibernate to disable all second level caching. Why would it put *anything* in the second level cache?


Top
 Profile  
 
 Post subject: Re: second level cache and entity inheritance
PostPosted: Thu Aug 05, 2010 12:54 am 
Newbie

Joined: Wed Aug 04, 2010 1:25 pm
Posts: 2
Hmm, my mistake. I mixed up the behavior of that property. Assuming instead hibernate.cache.use_second_level_cache=true. Will Hibernate use the test.Parent cache for test.Child entities?


Top
 Profile  
 
 Post subject: Re: second level cache and entity inheritance
PostPosted: Thu Aug 05, 2010 2:17 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Yes, entity hierarchies are always stored in the same second level cache region


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