Referential Integrity Exception question
kurtstam Jul 20, 2010 2:35 PMHi guys,
If I archive all items on a category, and then remove the category like so:
{code}
RulesRepository repo = getRepo();
repo.loadCategory( "/" ).addCategory( "testRemoveCategoryWithArchivedCat", "a" );
AssetItem as = repo.loadDefaultPackage().addAsset( "testRemoveCategoryWithArchivedAsset", "a", "testRemoveCategoryWithArchivedCat", "drl" );
as.checkin( "a" );
as.archiveItem(true);
repo.loadCategory( "testRemoveCategoryWithArchivedCat" ).remove();
repo.save();
{code}
then it throws a ReferentialIntegrityException:
org.drools.repository.RulesRepositoryException: javax.jcr.ReferentialIntegrityException
at org.drools.repository.RulesRepository.save(RulesRepository.java:1149)
at org.drools.repository.CategoryItemTest.testRemoveCategoryLinkedWithArchived(CategoryItemTest.java:175)
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 junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
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)
Caused by: javax.jcr.ReferentialIntegrityException
at org.modeshape.jcr.JcrSession.checkReferentialIntegrityOfChanges(JcrSession.java:1318)
at org.modeshape.jcr.JcrSession.save(JcrSession.java:1330)
at org.drools.repository.RulesRepository.save(RulesRepository.java:1140)
... 20 more
Is this the expected behavior? Or can I add a config option to 'cascade delete'?
Thx,
--Kurt