-->
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: Placing arbitrary collections in the second-level cache
PostPosted: Sat Feb 11, 2006 2:03 pm 
Newbie

Joined: Sat Feb 11, 2006 1:31 pm
Posts: 3
Location: New York, NY
As far as I can tell, Hibernate is great at putting three kinds of objects into the second-level cache.

1. Mapped entities
2. Collections of the above that are mapped as one-to-many or many-to-many relations
3. Query results

But is it possible to cache a collection of mapped entities that results from some arbitrary operation?

I have a method:

Code:
public List obtainTheList(A ojbA) {
    //Load up objects of Class B
    //Do some logic to get objects of Class C
    //Finally use these objects to get a list of Class D
    return listOfD;
}


where classes A, B, C, D are all mapped entities. This operation to get listOfD from objA is expensive and would be ideal for caching. And it also doesn't lend itself easily to being expressed as a single query. In this example, the second-level cache is configured for classes A and D but not for B or C.

Does anyone know if it is possible to stuff the results into the second-level cache?

I'm using Ehcache as my cache provider, and I could certainly do this manually, but Hibernate does a lot of handy things when it puts a collection into the second-level cache. It would be time-consuming and error-prone for me to attempt to copy that mechanism.

For instance, it would be best to cache only the ids of listOfD and then pull the objects separately out of the cache for D.

I know Hibernate does this for mapped collections (#2 above). Is there a way to use it for collections that result from arbitrary operations?


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.