This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes handling multiple class versions in Hibernate L2 cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "handling multiple class versions in Hibernate L2 cache" Watch "handling multiple class versions in Hibernate L2 cache" New topic
Author

handling multiple class versions in Hibernate L2 cache

Y Perry
Greenhorn

Joined: Sep 20, 2012
Posts: 1
Hi,

I have several servers using Hibernate 3.3 for reading/writing objects of class 'C'. Every once in a while I modify the DB schema (i.e. add new fields), and update class 'C' accordingly.
As I was planning to add an L2 cache (memcached) for performance reasons, I stumbled across the following problem:

The upgrade process takes an hour or so, during which the servers are upgraded one after the other.
If a server that was already upgraded tries to fetch an object from the cache, and this object was not yet modified in the Cache to include the new fields, Hibernate generates an 'ArrayOutOfBounds' Exception upon trying to de-serialize the old shorter object using the new longer definition.

Is there an elegant way avoid this exception, e.g. override the serialization process?
Is there a better way to tackle this issue altogether?

Please note that this problem has nothing to do with with the actual cache mechanism. The 'problematic' code is in Hibernate: TypeFactory.assemble().
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: handling multiple class versions in Hibernate L2 cache
 
Similar Threads
Getting JPanel size
Mapping DB columns to Object
Clearing L2 Cache using hibernate
generics
Mapping DB columns to Objects