My Spring/Hibernate Versions:
spring 2.5.6
hibernate-3.2.2.ga
hibernate-annotations-3.2.1.ga
hibernate-entitymanager-3.2.1.ga
I have an AspectJ pointcut that is intercepting the known 'save/update' methods for a JPA EntityManager but am unsure how to know during a cascading-save what method is actually being called on the children???
The documentation claims:
#If a parent is passed to persist(), all children are passed to persist()
#If a parent is passed to merge(), all children are passed to merge()
#If a parent is passed to save(), update() or saveOrUpdate(), all children are passed to saveOrUpdate()
#If a transient or detached child becomes referenced by a persistent parent, it is passed to saveOrUpdate()
Here is scenario :
Code:
ParentObject parentObject = entityManger.find( ... );
parentObject.addChild(new ChildObject());
parentObject.addChild(new ChildObject2());
parentObject.addChild(new ChildObject3());
entityManger.persist(parentObject);
While the pointcut catches the persist on the parentObject, it seems to not know or catch which method updates/saves the childObject.
Any answers would be great.
Ive been able to intercept all calls to merge/persist/remove without an issue, but on a collection it seems to be missing...... (keep in mind parentObject and childObject are two different Objects types and I can see the parentObject in a persist( ) but the childObject I can't seem to know which method it is using)
Here are my pointcuts.
Code:
@Pointcut("call(void javax.persistence.EntityManager.persist(*))")
public void weaveInGlobalPersistenceChecks() {}
@Pointcut("call(* javax.persistence.EntityManager.merge(*))")
public void weaveInGlobalMergeChecks() {}
@Pointcut("call(void javax.persistence.EntityManager.remove(*))")
public void weaveInGlobalDeleteChecks() {}
What could I be missing? How can I log what is saving the childObjects?