Brett Meyer, I have created a test case that demonstrates this issue on Hibernate 4.3.8. I don't see any way to attach files, so here is the Jar file: https://drive.google.com/file/d/0BxqZnkD8-hBvWm5FWW9jMWJZOTA/view?usp=sharing
The code uses a very simple data class with JPA annotations and an H2 in-memory database with DDL generation turned on. It uses Maven to resolve dependencies and should be fairly simple to run. The test method that demonstrates this problem is net.gaggle.hibernateTesting.TestHibernateInterceptor.testOnFlushDirtyPersistentMapState(). This illustrates that the currentState and previousState values passed into interceptor contain the exact same values for the PersistentMap, even though those values have changed. However, as mentioned by Rob West above, the previous values are available in the getStoredSnapshot method, so I have created a "hacked" mode for my custom interceptor that shows how the previousState can be modified based on this along with examining the isDirty method of the PersistentMap. This is very clearly a hack, since the docs state that previousState should not be modified, but it may provide a workaround for others who are affected.
I have another test case within here that illustrates the problem in
HHH-4897
, which I already commented on in that Jira.
|