Hi, folks. I am working on a JPA setup with optimistic locking (@Version) and EHCache. The underlying provider is Hibernate.
I hooked a HibernateDirtyCheckInterceptor (extends EmptyInterceptor) into the Spring config file. This part is working, as my log entries get posted. My entity class clearly defines itself as not dirty, and the findDirty method of the interceptor properly returns int[0] as the return value, to specify that the entity is not dirty.
When the onFlushDirty() is called, it still sees the entities I mark as not dirty. They are updated (they are the 1 part of a 1-M relationship with a Collection). They are in a 1-M association.
Surprisingly, when the entity is not having its Collection augmented, it is not updated, even when it is itself updated, so the interceptor does its job. I would imagine this rules out any issues with optimistic locking and the EHCache.
That leaves the question: how do I make sure that whenever a Collection is involved, the entity is not updated? This is a classic example of a bi-directional one to many association, where the one part is updated when a new entry is made to the many part.
Thank you for your reply!