if (methodName.startsWith("makePersistent")) {
Object object = arguments[0];
log.debug( "Intercepting call to make persistent for " + object.toString() );
if( object instanceof LifecycleCallbacks ) {
LifecycleCallbacks lifecycle = (LifecycleCallbacks) object;
if( lifecycle.getId() != null ) {
lifecycle.beforeUpdate();
} else {
lifecycle.beforeCreate();
}
lifecycle.beforeSave();
} else {
log.debug( "Object doesn't implement lifecycle callbacks, not running before.." );
}
returnObject = methodInvocation.proceed();
if( object instanceof LifecycleCallbacks ) {
LifecycleCallbacks lifecycle = (LifecycleCallbacks) object;
if( lifecycle.getId() != null ) {
lifecycle.afterUpdate();
} else {
lifecycle.afterCreate();
}
lifecycle.afterSave();
} else {
log.debug( "Object doesn't implement lifecycle callbacks, not running after.." );
}
} else if( methodName.startsWith( "makeTransient" ) ) {