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: persister isCacheInvalidationRequired() for Immutables
PostPosted: Tue Jan 04, 2011 4:10 pm 
Newbie

Joined: Fri Dec 21, 2007 10:20 am
Posts: 5
Hello,

I noticed that the method isCacheInvalidationRequired() in AbstractEntityPersister only checks for versioning as a way of "forcing" potentially dangerous cache updates.

I have simple immutable POJOs. Therefore no versioning (as that would defeat the purpose of having a read-only cache since version updates are indeed UPDATES), no dynamic updates, no formula properties; just run of the mill POJOs however some being spanned across several tables (using a subclass per hierarchy mapping).

If the objects being stored are in need immutable (mutable="false") why won't the persister allow the second-level cache update (which in my case is Ehcache)?

I really don't feel like adding my own persister for every entity which is subject to this behavior. Does this code change sound completely crazy or potentially dangerous?

Code:
public boolean isCacheInvalidationRequired() {
      return hasFormulaProperties() ||
            ((!isVersioned() || !isMutable()) && ( entityMetamodel.isDynamicUpdate() || getTableSpan() > 1 ) );
}


Thanks for any help.


Top
 Profile  
 
 Post subject: Re: persister isCacheInvalidationRequired() for Immutables
PostPosted: Wed Jan 05, 2011 8:34 am 
Newbie

Joined: Fri Dec 21, 2007 10:20 am
Posts: 5
I'm sorry the correct fix would be:
Code:
public boolean isCacheInvalidationRequired() {
      return hasFormulaProperties()
            || (!isVersioned() && (entityMetamodel.isDynamicUpdate() || (getTableSpan() > 1 && isMutable())));
   }


That way upon transaction completion, if sucessful and this method is invoked, it doesn't matter how many tables the entity spans since the entity is immutable


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.