| I have attached an implementation using AspectJ that is 2nd level cache provider agnostic, but I did that for old Hibernate version 3.6.10.Final. I initially wanted to optimize in some of the case the invalidation by checking first if it's the second level cache or the first level that is older but I didn't do that. If someone knows how to find 'references' to constructor of StaleObjectStateException, it could redo it for more recent version of Hibernate, see file HibernateInvalidateWhenStaleObjectStateException in attachment HibernateSandboxOptimisticLock.zip |