I am trying to persist an entity A, which has a many-to-one relationship to entity B which it holds as an instance member.
I have defined the relationship in A.hbm.xml with cascade="save-update".
However because I am working with a legacy system, I need to alter the state of A, B in the same way for save and update.
In fact I am adding modifiedOn, modifiedBy, createdOn, createdBy properties and obtaining identifiers in a custom way.
I decided the best way to do this was using the Event Listener API.
So I have defined a listener for Save and one for Update.
When I persist B on its own it works fine.
When I add a transient B to A and try to persist A, the listener is not called on B hence cascade save cannot happen.
Doesn't the event api get called for entities that are being saved by cascade?
|