Announcement Announcement Module
Collapse
No announcement yet.
Caching: Composite Keys Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Caching: Composite Keys

    Hello,

    we have a requirement to cache the result of a method determining if two entities 'fit together'.
    Therefore we have a key that consists of both entities' identifiers. Cached result is the boolean.

    Now when one of the entities is updated we want to evict the cache entries with keys containing this entity. For the other entity we evict all cache entries.

    Unfortunately this does not work because of the hashCode() implementation that is used by the eh-Cache. There is no way to achieve this requirement. When we build hashcode with only one of the entities' identifiers the cache eviction works, but all requests will be provided from cache even if the 2nd entity is different. When the hashCode is built from both entities' identifiers the cached is only used when both entities match but we cannot evict a set of entries (having a specific value of entity1).

    Has anybody solved such an issue involving a Composite-Key?

    thanks.

  • #2
    Problem solved. Thread may be closed

    In my case the hashCode implementation is built with only one entity but equals implementation must compare both (if the 2nd entity is not null)

    Comment

    Working...
    X