I just discovered a serious flaw in the PK cache (EntityCache.java): GenericPK is used as a cache key. This is bad for two reasons:

1. GenericPK is mutable and its hash code changes over time. It can be made immutable before adding it to the cache. 2. The equals method is implemented by the GenericEntity super class - which compares ALL fields, not just primary key fields. So, the PK cache can contain multiple versions of the same PK.

I'm trying to decide how to fix this. My preferences would be to override equals() and hashCode() in GenericPK so that it behaves as expected, but that might break a lot of code. The other option would be create a String cache key from the GenericPK instance.

--
Adrian Crum
Sandglass Software
www.sandglass-software.com

Reply via email to