openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Struberg <strub...@yahoo.de>
Subject ManagedCache cache issues?
Date Wed, 11 Jan 2012 22:58:34 GMT
hi!

I'm debugging through a weird bug I have here locally. While doing that I figured that the
the cache could suffer from clashes 



ManagedCache.java

StateManagerImpl orig = _main.put(sm.getObjectId(), sm);

the problem is that the same instance of the ManagedCache is being used for different Entities.
But for different entities, the ids could be overlapping!

I'm e.g. using
<property name="openjpa.Sequence" value="class-table(Table=SEQUENCES, Increment=20, InitialValue=10000)"/>

Which means that there could be a Customer with id=10001 and an Address with id=10001.
Some query which would touch both would create a clash in the ManagedCache.

It might (and reasonably ok performance wise) be safe to add something like

int entityHash = sm.getPersistenceCapable().getClass().hashCode();

StateManagerImpl orig = _main.put(entityHash + (29 * sm.getObjectId()), sm);


wdyt?

LieGrue,
strub

Mime
View raw message