Hi All (Again :)
I've got the following code:
@Override
protected void onPrePersist() {
this.deleteIfEmptyCode();
}
@Override
protected void onPreUpdate() {
this.deleteIfEmptyCode();
}
private void deleteIfEmptyCode() {
if (StringUtils.isBlank(getProductCode())) {
if (null != getObjectContext())
getObjectContext().deleteObject(this);
}
}
This code works perfectly via the preUpdate callback, however I get an
exception when the delete happens via a prePersist specifically when
the PersistenceState is NEW the exception is and it happens when I try
to commit the changes to the database.
java.lang.NullPointerException
at org.apache.cayenne.reflect.LifecycleCallbackEventHandler.performCallbacks(LifecycleCallbackEventHandler.java:170)
at org.apache.cayenne.reflect.LifecycleCallbackEventHandler.performCallbacks(LifecycleCallbackEventHandler.java:134)
at org.apache.cayenne.reflect.LifecycleCallbackEventHandler.performCallbacks(LifecycleCallbackEventHandler.java:151)
at org.apache.cayenne.reflect.LifecycleCallbackRegistry.performCallbacks(LifecycleCallbackRegistry.java:142)
at org.apache.cayenne.access.DataChannelSyncCallbackAction.apply(DataChannelSyncCallbackAction.java:82)
at org.apache.cayenne.access.DataChannelSyncCallbackAction$FlushCallbackAction.applyPostCommit(DataChannelSyncCallbackAction.java:178)
at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:800)
at org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1106)
at org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
at au.riva.site.db.entity.MarketingCampaignProductTest.testOnPrePersist(MarketingCampaignProductTest.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Thank you all for all the assistance
Gary
This archive was generated by hypermail 2.0.0 : Fri Jul 30 2010 - 08:57:36 UTC