Uploaded image for project: 'Isis'
  1. Isis
  2. ISIS-1119

Bi-Directional 1-1 rel. throws MetaModelException if invoking setter with @Persistent(mappedBy=)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: core-1.8.0
    • Fix Version/s: tidy-up
    • Component/s: Core: Objectstore: JDO
    • Labels:
      None

      Description

      I have 2 bi-directional entities with properties defined as:

      Entity 1 property:

      public class Kit {
      
          // {{ RegisteredForPerson (property)
          private Person registeredForPerson;
      
          // Must be updated through the Action !!!
          @Property(editing = Editing.DISABLED)
          @MemberOrder(sequence = "1")
          @Column(allowsNull = "true")
          public Person getRegisteredForPerson() {
              return this.registeredForPerson;
          }
      
          public void setRegisteredForPerson(final Person registeredForPerson) {
              this.registeredForPerson = registeredForPerson;
          }
      
          // }}
      
      }
      

      Entity 2 property:

      public class Person {
      
          // {{ RegisteredKit (property)
          private Kit registeredKit;
      
          @MemberOrder(sequence = "010")
          @Property(editing = Editing.DISABLED)
          @Column(allowsNull = "true")
          @Persistent(mappedBy = "registeredForPerson")
          public Kit getRegisteredKit() {
              return this.registeredKit;
          }
      
          public void setRegisteredKit(final Kit registeredKit) {
              this.registeredKit = registeredKit;
          }
      
          // }}
      
      }
      

      As per [1], seems DataNucleus require bi-directional 1-1 relationships to be maintained at both sides by the programmer (they're not automatically managed).

      [1] http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_one.html#bi

      So I must set both sides:

                  this.setRegisteredKit(kit);
      
                  // A 1-1 bi-directional relationship must be maintained at both
                  // sides, as per:
                  // http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_one.html#bi
                  kit.setRegisteredForPerson(this);
      
      

      But that generates an StackOverflowException, when executing the first setter:

                  this.setRegisteredKit(kit);
      
      

      Same exception happens also if the setters order is inverted. So it's a matter of executing the setter annotated with @Persistent(mappedBy="")

                  // A 1-1 bi-directional relationship must be maintained at both
                  // sides, as per:
                  // http://www.datanucleus.org/products/datanucleus/jdo/orm/one_to_one.html#bi
                  kit.setRegisteredForPerson(this);
      
                  // Will fail when executing this next setter, now:
                  this.setRegisteredKit(kit);
      
      

      java.lang.RuntimeException: org.apache.isis.core.metamodel.exceptions.MetaModelException: java.lang.StackOverflowError
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:337)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:346)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.preDirtyProcessingFor(FrameworkSynchronizer.java:229)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener$4.doRun(IsisLifecycleListener.java:111)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener$RunnableAbstract.run(IsisLifecycleListener.java:206)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener.withLogging(IsisLifecycleListener.java:185)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener.preDirty(IsisLifecycleListener.java:107)
      at org.datanucleus.api.jdo.JDOCallbackHandler.preDirty(JDOCallbackHandler.java:262)
      at org.datanucleus.state.JDOStateManager.updateField(JDOStateManager.java:2007)
      at org.datanucleus.state.JDOStateManager.setObjectField(JDOStateManager.java:1935)
      at com.tellmegen.domain.model.accounts.Person.setRegisteredKit(Person.java)
      at com.tellmegen.domain.model.accounts.Person.registerKit(Person.java:161)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.internalInvoke(ActionInvocationFacetForDomainEventAbstract.java:337)
      at org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacetForDomainEventAbstract.invoke(ActionInvocationFacetForDomainEventAbstract.java:189)
      at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:57)
      at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction$1.execute(ActionInvocationFacetWrapTransaction.java:1)
      at org.apache.isis.core.runtime.system.transaction.IsisTransactionManager.executeWithinTransaction(IsisTransactionManager.java:205)
      at org.apache.isis.core.runtime.transaction.facets.ActionInvocationFacetWrapTransaction.invoke(ActionInvocationFacetWrapTransaction.java:54)
      at org.apache.isis.core.metamodel.specloader.specimpl.ObjectActionImpl.execute(ObjectActionImpl.java:367)
      at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.handleActionMethod(DomainObjectInvocationHandler.java:610)
      at org.apache.isis.core.wrapper.handlers.DomainObjectInvocationHandler.invoke(DomainObjectInvocationHandler.java:244)
      at org.apache.isis.core.wrapper.proxy.ProxyInstantiatorForJavassist$1.invoke(ProxyInstantiatorForJavassist.java:52)
      at com.tellmegen.domain.model.accounts.Person_$$jvstef_5.registerKit(Person$$_jvstef_5.java)
      at com.tellmegen.domain.model.kits.Kit.assignToPerson(Kit.java:163)
      at com.tellmegen.integtests.domain.model.kits.KitTests.tenancy_accountHasAccessToHisKits(KitTests.java:109)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2$1.evaluate(JUnitRuleMockery2.java:146)
      at org.apache.isis.core.integtestsupport.ExceptionRecognizerTranslate$TranslationStatement.evaluate(ExceptionRecognizerTranslate.java:32)
      at org.apache.isis.core.integtestsupport.IntegrationTestAbstract$IsisTransactionRule$1.evaluate(IntegrationTestAbstract.java:214)
      at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
      at org.junit.rules.RunRules.evaluate(RunRules.java:20)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
      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: org.apache.isis.core.metamodel.exceptions.MetaModelException: java.lang.StackOverflowError
      at org.apache.isis.core.commons.lang.ThrowableExtensions.throwWithinIsisException(ThrowableExtensions.java:60)
      at org.apache.isis.core.commons.lang.MethodExtensions.invoke(MethodExtensions.java:57)
      at org.apache.isis.core.commons.lang.MethodExtensions.invoke(MethodExtensions.java:47)
      at org.apache.isis.core.metamodel.adapter.ObjectAdapter$InvokeUtils.invoke(ObjectAdapter.java:346)
      at org.apache.isis.core.metamodel.facets.properties.accessor.PropertyAccessorFacetViaAccessor.getProperty(PropertyAccessorFacetViaAccessor.java:73)
      at org.apache.isis.core.metamodel.specloader.specimpl.OneToOneAssociationImpl.get(OneToOneAssociationImpl.java:131)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction$AdapterAndProperty.getPropertyValue(IsisTransaction.java:1179)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction$AdapterAndProperty.access$0(IsisTransaction.java:1178)
      at org.apache.isis.core.runtime.system.transaction.IsisTransaction.enlistUpdating(IsisTransaction.java:1332)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$4.run(FrameworkSynchronizer.java:259)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$8.call(FrameworkSynchronizer.java:350)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer$8.call(FrameworkSynchronizer.java:1)
      at org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.withLogging(FrameworkSynchronizer.java:335)
      ... 58 more
      Caused by: java.lang.StackOverflowError
      at org.datanucleus.properties.PropertyStore.hasProperty(PropertyStore.java:65)
      at org.datanucleus.ExecutionContextImpl.getBooleanProperty(ExecutionContextImpl.java:868)
      at org.datanucleus.TransactionImpl.getOptimistic(TransactionImpl.java:634)
      at org.datanucleus.api.jdo.state.PersistentNontransactional.transitionReadField(PersistentNontransactional.java:151)
      at org.datanucleus.state.AbstractStateManager.transitionReadField(AbstractStateManager.java:650)
      at org.datanucleus.state.JDOStateManager.isLoaded(JDOStateManager.java:3194)
      at com.tellmegen.domain.model.accounts.Account.getApplicationUser(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoGetemail(Account.java:76)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyField(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyFields(Account.java)
      at org.datanucleus.state.JDOStateManager.saveFields(JDOStateManager.java:694)
      at org.datanucleus.api.jdo.state.PersistentNontransactional.transitionReadField(PersistentNontransactional.java:154)
      at org.datanucleus.state.AbstractStateManager.transitionReadField(AbstractStateManager.java:650)
      at org.datanucleus.state.JDOStateManager.isLoaded(JDOStateManager.java:3194)
      at com.tellmegen.domain.model.accounts.Account.getApplicationUser(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoGetemail(Account.java:76)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyField(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyFields(Account.java)
      at org.datanucleus.state.JDOStateManager.saveFields(JDOStateManager.java:694)
      at org.datanucleus.api.jdo.state.PersistentNontransactional.transitionReadField(PersistentNontransactional.java:154)
      at org.datanucleus.state.AbstractStateManager.transitionReadField(AbstractStateManager.java:650)
      at org.datanucleus.state.JDOStateManager.isLoaded(JDOStateManager.java:3194)
      at com.tellmegen.domain.model.accounts.Account.getApplicationUser(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoGetemail(Account.java:76)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyField(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyFields(Account.java)
      at org.datanucleus.state.JDOStateManager.saveFields(JDOStateManager.java:694)
      at org.datanucleus.api.jdo.state.PersistentNontransactional.transitionReadField(PersistentNontransactional.java:154)
      at org.datanucleus.state.AbstractStateManager.transitionReadField(AbstractStateManager.java:650)
      at org.datanucleus.state.JDOStateManager.isLoaded(JDOStateManager.java:3194)
      at com.tellmegen.domain.model.accounts.Account.getApplicationUser(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoGetemail(Account.java:76)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyField(Account.java)
      at com.tellmegen.domain.model.accounts.Account.jdoCopyFields(Account.java)
      at org.datanucleus.state.JDOStateManager.saveFields(JDOStateManager.java:694)

        Attachments

          Activity

            People

            • Assignee:
              danhaywood Daniel Keir Haywood
              Reporter:
              oscarbou Óscar Bou
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: