-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Fri Feb 08, 2013 6:05 am 
Newbie

Joined: Thu Apr 26, 2012 3:23 am
Posts: 3
dear all,

I am Using Hibernate 3.3 with EHCache 2.6 as provider for the second level cache. As far as i know, hibernate
does not support caching of subclasses. Is there any workaround available.
Is this maybe solved with latest Hibernate 4.x Version? Could i need another Cache-Backend to get it working?

Thanx very much for your help :-)

yours,
Shannon


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Tue Feb 12, 2013 4:45 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
As far as i know, hibernate does not support caching of subclasses.


That's simply not true.
Where did you hear that?


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Thu Feb 14, 2013 12:42 pm 
Newbie

Joined: Thu Apr 26, 2012 3:23 am
Posts: 3
Ive read in several posts that people do have problems configuring Hibernate+2nd Level cache when
trying to cache subclasses (B extends A). I saw the similar effect that subclasses (class B) is not put into cache
or does have some cache hits. I verified this by hibernate statistics.

I found a post showing how this could be arranged:
http://moresbycoffee.blogspot.de/2012/04/coffee-moth-hibernate-l2-cache-and.html

but i am wondering that the caching of subclasses is not working out-of-the-box.
Is there something i have not taken into account to enable subclass-caching?
Thanks again for any help

yours,
Shannon


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Fri Feb 15, 2013 6:51 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Well the poster you report was using Hibernate 3.3.2 GA which is a rather old hibernate version.
I use Hibernate4 (and Hibernate3.6 formerly) with EHCache 2.5.1 as 2L-implementatipm
and expect HHH-4953 I did not encounter any problem with subclass caching.
To precise is, that I use Single-Table per hierarchy inheritance strategy only.


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Sun Mar 03, 2013 7:58 am 
Newbie

Joined: Sun Nov 04, 2012 2:43 am
Posts: 2
Hi,

A while ago, I was facing the same issue of not being able to have a per subclass cache configuration and I saw same cache statstics as Shannon. We are using Hibernate4. I am not sure, but it could be influanced by the inheretance strategy used. We have patched hibernate to have addiitonal property "hibernate.cache.force_per_subclass_second_level_cache=true" and it seems to work fine so far. I am not sure if it will have other side effects in other areas. It would be great if I can get a feedback about this. The older post is https://forum.hibernate.org/viewtopic.php?p=2466300

Regards,
hshicx


Top
 Profile  
 
 Post subject: Re: Hibernate Second Level Cache with Sublasses Strategy
PostPosted: Mon Mar 04, 2013 6:18 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Hi,

Ok, saying 'hibernate does not support caching of subclasses' is a somewhat different statement than saying
'hibernate does not support have a per subclass cache configuration'.
While first statement is definitely false the latter might be true quite.
I must admit that I never needed and therefore tested a 'per subclass cache configuration'...


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