Uploaded image for project: 'Hibernate ORM'
  1. HHH-11766

Accessing lazy basic property on entity loaded from 2nd level cache throws exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.10, 5.3.0.CR1, 5.1.13
    • Fix Version/s: 5.2.17, 5.3.0.CR2, 5.1.14
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      Basic description:
      If an entity with a lazy basic attribute is loaded from the second level cache and the lazy attribute is accessed an exception is thrown. The reason seems to be that the cache entry for the entity attribute yields an instance of org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY which is not handled. Due to the missing handling org.hibernate.persister.entity.AbstractEntityPersister goes ahead and tries to assign the field from it.

      Maybe a duplicate/relative of HHH-9435 Awaiting Response which I was not able to determine given the specific environment/reproducer. This one is definitely reproducible on Version 5.2.10

      Steps to reproduce:
      1. Unzip attached reproducer which is derived from hibernate-test-case-templates/orm/hibernate-orm-5
      2. Run "mvn clean verify"

      Please note that as bytecode enhancement had to be enabled for test classes the pom.xml has been adapted.

      Stacktrace:

      IllegalArgumentException occurred while calling setter for property [org.hibernate.bugs.entities.Person.lazyAttribute (expected type = java.lang.String)]; target = [org.hibernate.bugs.entities.Person@44c79f32], property value = [<lazy>]
      	at org.hibernate.property.access.spi.EnhancedSetterImpl.set(EnhancedSetterImpl.java:118)
      	at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValue(AbstractEntityTuplizer.java:716)
      	at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValue(AbstractEntityPersister.java:4701)
      	at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyProperty(AbstractEntityPersister.java:1175)
      	at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyPropertiesFromCache(AbstractEntityPersister.java:1158)
      	at org.hibernate.persister.entity.AbstractEntityPersister.initializeLazyProperty(AbstractEntityPersister.java:994)
      	at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor$1.doWork(LazyAttributeLoadingInterceptor.java:105)
      	at org.hibernate.bytecode.enhance.spi.interceptor.Helper.performWork(Helper.java:97)
      	at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.loadAttribute(LazyAttributeLoadingInterceptor.java:76)
      	at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.fetchAttribute(LazyAttributeLoadingInterceptor.java:72)
      	at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.intercept(LazyAttributeLoadingInterceptor.java:61)
      	at org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.readObject(LazyAttributeLoadingInterceptor.java:296)
      	at org.hibernate.bugs.entities.Person.$$_hibernate_read_lazyAttribute(Person.java)
      	at org.hibernate.bugs.entities.Person.getLazyAttribute(Person.java:38)
      	at org.hibernate.bugs.JPAUnitTestCase.loadPersonAndAccessLazyPropertyTx3(JPAUnitTestCase.java:89)
      	at org.hibernate.bugs.JPAUnitTestCase.errorLoadingFromCacheWithLazyPropertyTest(JPAUnitTestCase.java:58)
      	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:47)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
      	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
      	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
      	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
      	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
      Caused by: java.lang.IllegalArgumentException: argument type mismatch
      	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.hibernate.property.access.spi.EnhancedSetterImpl.set(EnhancedSetterImpl.java:61)
      	... 40 more
      
      
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                9 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: