Hibernate version:
3.1.2 (brand new ;-) )
Problem:
I am using the "new"
onCollectionRecreate(Object collection, Serializable key) and
onCollectionUpdate(Object collection, Serializable key) methods in the
org.hibernate.Interceptor to implement an audit trail in the interceptor.
For that reason I cast the given collection to a PersistentCollection if possible and use the getRole()-method to determine which collection has been altered.
Code:
public void onCollectionUpdate(Object collection, Serializable key) throws CallbackException {
if (collection instanceof PersistentCollection) {
PersistentCollection pc = (PersistentCollection) collection;
System.out.println("Update on "+pc.getRole()+":"+ key.toString());
}
}
This approach works fine for me in the update scenario, the output is as expected.
But for the recreate case where I just created a new Entity, saved [session.save(entity)] and then flushed it I just get a "null" from pc.getRole().
Is this the intended behaviour? Am I missing something?
I tried to wade through the Hibernate code and see where that role is set, but these paths back to the HbmBinder are very tricky :-(.
Any thoughts anyone?