The test case I created utilizes two entities: a base and an extended. These entities have natural ID on the base entity.
*Scenario:* 1. Create and persist a base entity and an extended entity 2. Load the extended entity using the natural ID of the base entity. This is done using the code below.
{code} ExtendedEntity user = s.byNaturalId(ExtendedEntity.class).using("uid", "base").load(); assertNull(user); {code}
*Expected behavior:* The returned entity should be null, according to documentation in org.hibernate.NaturalIdLoadAccess<T>#load().
*Actual behavior if second level cache is _ENABLED_:* WrongClassException is thrown, because it finds the base entity in the second level cache and tries to use that.
*Actual behavior if second level cache is _DISABLED_:* The returned entity is null. This is also the expected behavior.
*Bonus behavior if second level cache is _DISABLED_ and debug logging is enabled on {{org.hibernate.event.internal.AbstractFlushingEventListener}} AND {{org.hibernate.internal.util.EntityPrinter}}:* In 5.0.11, PropertyAccessException will be thrown. In the latest master branch (based on commit 7b78ee99), PersistenceException will be thrown with PropertyAccessException as cause.
I've run the testcases on a branch based on master@7b78ee99 and on a branch based on tag 5.0.11, since 5.0.11 is what's currently being using in JBoss EAP 7.
The source code for my tests are available here: https://github.com/ trew hibernate /hibernate-orm/ commit/185cc96309c2672fe97be77f2f851a714f23a3df
Should I create a pull request even though I only have the tests and no solution? /1813 |
|