We are using Hibernate event model to implement transparent localization of POJOs. It is implemented as
PreUpdateEventListener and PostUpdateEventListener so that a POJO is manipulated at PreUpdateEventListener
before letting Hibernate to persist it. The original state is restored at PostUpdateEventListener so that subsequent snapshot comparisons match. This strategy works with Hibernate 3.0 but fails with 3.1. The reason for
failing with 3.1 is the addition of following code block:
Code:
// get the updated snapshot by cloning current state
// it is safe to copy in place, since by this time
// no-one else has a reference to the array
TypeFactory.deepCopy(
state,
persister.getPropertyTypes(),
persister.getPropertyCheckability(),
state,
session
);
This happens before PostUpdateEventListener.onPostUpdate is called, so we do not have a chance to restore
the manipulated entity to its original state.
What is the rationale behind this added code block?
Is there any other way to implement the feature described above?
Thnx, Joni
Code: