Okay, #2 is not a problem. When the GenericPK instance is created it only contains pk fields. I still need to fix #1.

Adrian Crum
Sandglass Software
www.sandglass-software.com

On 3/20/2015 6:09 PM, Adrian Crum wrote:
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.

Reply via email to