Hellu all,
I like to intercept the changes on an associated object, but don't know how.
Example: Person has a collection of adresses. The addresses are value type objects. I want to change the date created/date updated fields in the address, just before they are updated in the db.
In the hibernate interceptor the onSave method get called whenever Person is saved, but not when Address is saved.
Then you have the methods onCollectionRecreate and onCollectionUpdate that I think should be used for this purpose, but I don't really understand their usage.
For example, the signature of one of them:
Code:
onCollectionUpdate(Object collection, Serializable key)
But the key is unknown as it's the person Id, but that's the foreign key and we can't use that in our collection that only contains Addresses and doesn't have any method to retrieve the object through this user id...
Also I noticed that this method receive the whole collection, so also the Addresses that aren't changed...
Hmmm... I noticed some other people had the questions about this usage as well, but never got an answer..
So I hope I have more luck and somebody can give me a bit of advice on this subject.
I read the Auditable examples in the books and wiki, but they don't talk about associations...
Regards,
Ed