java.lang.RuntimeException: IMMEDIATE_LOAD:eu.pinske.model.Child#1

Hibernate JIRA | Alexander Pinske | 8 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    When bytecode enhancement (enableDirtyTracking) is activated, a flush triggers a load on every proxy instance. The problems seems to be that the proxy is "around" the ManagedEntity implementation (which is this case is the not-loaded entity). Therefore the proxy is accessed to check the entity state. This access causes the load. Find attached a sample application. You can trigger the problem by running "mvn clean test". When enableDirtyTracking is deactivated, the problem does not occur and the "Child"-entity is not loaded (see also SQL statements). {noformat} 2016-07-04 00:21:30,448 DEBUG org.hibernate.SQL - select parent0_.id as id1_1_0_, parent0_.child_id as child_id2_1_0_ from Parent parent0_ where parent0_.id=? 2016-07-04 00:21:30,473 DEBUG org.hibernate.SQL - select child0_.id as id1_0_0_ from Child child0_ where child0_.id=? Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.852 sec <<< FAILURE! test(eu.pinske.test.LazyLoadTest) Time elapsed: 2.709 sec <<< ERROR! java.lang.RuntimeException: IMMEDIATE_LOAD:eu.pinske.model.Child#1 at eu.pinske.test.LazyLoadingListener.onLoad(LazyLoadingListener.java:13) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1213) at org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:1071) at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:156) at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:260) at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:68) at eu.pinske.model.Child_$$_jvst583_1.$$_hibernate_getEntityEntry(Child_$$_jvst583_1.java) at org.hibernate.engine.internal.EntityEntryContext.getEntityEntry(EntityEntryContext.java:158) at org.hibernate.engine.internal.StatefulPersistenceContext.getEntry(StatefulPersistenceContext.java:441) at org.hibernate.engine.spi.CascadingActions$8.isInManagedState(CascadingActions.java:397) at org.hibernate.engine.spi.CascadingActions$8.noCascade(CascadingActions.java:375) at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:119) at org.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:150) at org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:141) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:74) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1397) at eu.pinske.test.LazyLoadTest.test(LazyLoadTest.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) 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.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.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) {noformat}

    Hibernate JIRA | 8 months ago | Alexander Pinske
    java.lang.RuntimeException: IMMEDIATE_LOAD:eu.pinske.model.Child#1

    Root Cause Analysis

    1. java.lang.RuntimeException

      IMMEDIATE_LOAD:eu.pinske.model.Child#1

      at eu.pinske.test.LazyLoadingListener.onLoad()
    2. eu.pinske.test
      LazyLoadingListener.onLoad
      1. eu.pinske.test.LazyLoadingListener.onLoad(LazyLoadingListener.java:13)
      1 frame
    3. Hibernate
      JavassistLazyInitializer.invoke
      1. org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1213)
      2. org.hibernate.internal.SessionImpl.immediateLoad(SessionImpl.java:1071)
      3. org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:156)
      4. org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:260)
      5. org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:68)
      5 frames
    4. eu.pinske.model
      Child_$$_jvst583_1.$$_hibernate_getEntityEntry
      1. eu.pinske.model.Child_$$_jvst583_1.$$_hibernate_getEntityEntry(Child_$$_jvst583_1.java)
      1 frame
    5. Hibernate
      SessionImpl.flush
      1. org.hibernate.engine.internal.EntityEntryContext.getEntityEntry(EntityEntryContext.java:158)
      2. org.hibernate.engine.internal.StatefulPersistenceContext.getEntry(StatefulPersistenceContext.java:441)
      3. org.hibernate.engine.spi.CascadingActions$8.isInManagedState(CascadingActions.java:397)
      4. org.hibernate.engine.spi.CascadingActions$8.noCascade(CascadingActions.java:375)
      5. org.hibernate.engine.internal.Cascade.cascade(Cascade.java:119)
      6. org.hibernate.event.internal.AbstractFlushingEventListener.cascadeOnFlush(AbstractFlushingEventListener.java:150)
      7. org.hibernate.event.internal.AbstractFlushingEventListener.prepareEntityFlushes(AbstractFlushingEventListener.java:141)
      8. org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:74)
      9. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:38)
      10. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1397)
      10 frames
    6. eu.pinske.test
      LazyLoadTest.test
      1. eu.pinske.test.LazyLoadTest.test(LazyLoadTest.java:32)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    8. JUnit
      ParentRunner.run
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      5. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      6. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      7. org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      8. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      9. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      10. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      11. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      12. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      13. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      13 frames
    9. JUnit4 Provider
      JUnit4Provider.invoke
      1. org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
      2. org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
      3. org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
      3 frames
    10. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:498)
      4 frames
    11. SureFire
      ForkedBooter.main
      1. org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
      2. org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
      3. org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
      4. org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
      5. org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
      5 frames