-->
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.  [ 1 post ] 
Author Message
 Post subject: Second-level cache based on Criteria?
PostPosted: Mon May 24, 2010 1:32 pm 
Beginner
Beginner

Joined: Fri Jan 29, 2010 8:17 pm
Posts: 20
Location: Portland OR
Based on the documentation it seems one can only configure the second level cache to cache every instance of a class. Meaning the configuration is only at the class level.

Is it possible to specify that an entity be cached only if it matches some Criteria?

My use case is along the lines of having lots of incoming data, with each piece of incoming data requiring we select some state out of the DB to see if 1. the state is 'bad', 2. if the state would be made 'good' by processing the incoming data. I would want to only cache data for the entities where the state is currently 'bad'. Most of the time(95% or more), the data would not change the state, and the number of entities in a bad state are small. But constantly selecting state out of the DB per incoming piece of data to see if some bad state could be potentially cleared doesn't scale well.

I could of course manually manage a cache, but I'd have to hook into some Hibernate events to see if the transaction failed and rollback changes to the cache, or commit the cache, etc. Which are all problems already solved in general by Hibernate transaction + cache guarantees. Except that I don't see any way to be more specific to again cache only based on Criteria.

Is there anything existing that I can leverage here, or is the current extent of the functionality to only specify caching at the class level?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.