Hibernate version: hibernate 2.1.8
I am having a performance problem I am attempting to resolve with the secondary cache. The secondary cache for my collections is being used if I do the proper pre-fetch, and works wonderfully!! (ie. "left join fetch"). My problem is occurring outside of read scope after bulk inserts and/or updates. I do a bunch of object creates and relates (requiring collection insertions and/or updates), and this works great.
My session is closed, and then another is reopened. I have detached objects that reattach to the session, and then my problem occurs. All of my collections, which are newly generated, start needing to be retrieved from the database. Performance suffers greatly.
I've been digging into hibernate code and understand the where this is happening, and I even understand some of the why, after reading messages on this forum. Gavin stated, without explanation on the threads I read (admittedly, I only dug for an hour, but I did look hard for that hour!), that collections are intentionally evicted from the cache.
I believe this is probably the correct behavior for the general case. However, I desire more control for our application's case. How do I attain this control? I wish to have newly insert-ed and/or update-ed collections remain in the secondary cache.
Aside from writing my own cache implementation and ignoring the semantics of "evict" "lock" and "release", i'm at a loss as to where to go next. I would gladly implement any custom code that can help control this behavior--I'm not sure where that would be.
Specifically, I see that for entities special code is in place to determine what is able to be retained, based on version and other heuristics. None of that is available for collections.
Thanks for any help in advance and thanks for the great product.
|