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 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.
Added a Patch (
) that should fix this issue including a test which should verify that.
Should also fix the initialization of basic attributes from the second level cache which is problematic as well as described in and
@Badner: Thanks for taking care of this and your improvements. I took a quick look and the improvements seem to be good.
Thanks again for your help and for looking at the PR.
Fixed in master and 5.2 branches.
Fixed in 5.1 branch as well.