user2350626
user2350626

Reputation: 71

How to handle different structure of same Entity in Hibernate L2 cache with Coherence for caching

I am using Hibernate L2 cache with Coherence for caching in two different web services.

Scenario

Both are pointing to same table/schema and the package hierarchy is also same.

Now when fresh request for employeeId=1 comes to second web service, it fetches from the value from the database and caches the 3 columns; keeps the other 2 as null.

Now when a request for employeeId=1 comes from the first web service, it directly fetches from cache by providing 3 columns and returns the other 2 as null, even though in the database the 2 columns have non-null values.

Is there a way by which I can force it get these column from database?

Approaches already tried

  1. If I keep the columns in both the web services as same the problem goes away but this is not a acceptable solution in my scenario.
  2. I tried added different serialVersion but it doesn't work.
  3. Keeping the fully qualified name different works, but this is force us add overhead to performing manual eviction

Upvotes: 0

Views: 117

Answers (1)

thewaterwalker
thewaterwalker

Reputation: 324

You should be able to use the Evolvable interface for this, which will allow you to insert an object into the grid that is both forward and backward compatible. You just need to ensure that Second Webservice sets a lower version than First.

Upvotes: 0

Related Questions