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

5.2.15 regression: 'could not resolve property: attributes of: org.hibernate.test.inheritance.discriminator.JoinedInheritanceTest$BaseEntity' with FetchType.EAGER

    Details

    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • Last commented by a user?:
      true

      Description

      Upgrading hibernate-core-5.2.13 to 5.2.14 recently failed due to https://hibernate.atlassian.net/browse/HHH-12333 reported by me and https://hibernate.atlassian.net/browse/HHH-12332.

      Now, in hibernate-core 5.2.15 these issues seem to be fixed. However, a new one arises.

      Stack trace:

      Caused by: org.hibernate.QueryException: could not resolve property: attributes of: org.hibernate.test.inheritance.discriminator.JoinedInheritanceTest$BaseEntity
      	at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:69)
      	at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:63)
      	at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassPropertyTableNumber(AbstractEntityPersister.java:1965)
      	at org.hibernate.persister.entity.BasicEntityPropertyMapping.toColumns(BasicEntityPropertyMapping.java:46)
      	at org.hibernate.persister.entity.AbstractEntityPersister.toColumns(AbstractEntityPersister.java:1907)
      	at org.hibernate.persister.entity.JoinedSubclassEntityPersister.toColumns(JoinedSubclassEntityPersister.java:979)
      	at org.hibernate.loader.plan.build.internal.spaces.EntityQuerySpaceImpl.toAliasedColumns(EntityQuerySpaceImpl.java:47)
      	at org.hibernate.loader.plan.build.internal.spaces.JoinImpl.resolveAliasedLeftHandSideJoinConditionColumns(JoinImpl.java:62)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.addJoins(LoadQueryJoinAndFetchProcessor.java:261)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.renderCollectionJoin(LoadQueryJoinAndFetchProcessor.java:386)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.renderJoin(LoadQueryJoinAndFetchProcessor.java:153)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoin(LoadQueryJoinAndFetchProcessor.java:128)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoins(LoadQueryJoinAndFetchProcessor.java:123)
      	at org.hibernate.loader.plan.exec.internal.LoadQueryJoinAndFetchProcessor.processQuerySpaceJoins(LoadQueryJoinAndFetchProcessor.java:104)
      	at org.hibernate.loader.plan.exec.internal.AbstractLoadQueryDetails.generate(AbstractLoadQueryDetails.java:148)
      	at org.hibernate.loader.plan.exec.internal.EntityLoadQueryDetails.<init>(EntityLoadQueryDetails.java:90)
      	at org.hibernate.loader.plan.exec.internal.BatchingLoadQueryDetailsFactory.makeEntityLoadQueryDetails(BatchingLoadQueryDetailsFactory.java:61)
      	at org.hibernate.loader.entity.plan.AbstractLoadPlanBasedEntityLoader.<init>(AbstractLoadPlanBasedEntityLoader.java:82)
      	at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:103)
      	at org.hibernate.loader.entity.plan.EntityLoader.<init>(EntityLoader.java:38)
      	at org.hibernate.loader.entity.plan.EntityLoader$Builder.byUniqueKey(EntityLoader.java:83)
      	at org.hibernate.loader.entity.plan.EntityLoader$Builder.byPrimaryKey(EntityLoader.java:77)
      	at org.hibernate.loader.entity.plan.AbstractBatchingEntityLoaderBuilder.buildNonBatchingLoader(AbstractBatchingEntityLoaderBuilder.java:30)
      	at org.hibernate.loader.entity.BatchingEntityLoaderBuilder.buildLoader(BatchingEntityLoaderBuilder.java:59)
      	at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2438)
      	at org.hibernate.persister.entity.AbstractEntityPersister.createEntityLoader(AbstractEntityPersister.java:2460)
      	at org.hibernate.persister.entity.AbstractEntityPersister.createLoaders(AbstractEntityPersister.java:4074)
      	at org.hibernate.persister.entity.AbstractEntityPersister.postInstantiate(AbstractEntityPersister.java:4056)
      	at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:203)
      	at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:300)
      	at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:458)
      	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
      	at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.buildSessionFactory(BaseCoreFunctionalTestCase.java:113)
      	at org.hibernate.testing.junit4.BaseCoreFunctionalTestCase.buildSessionFactory(BaseCoreFunctionalTestCase.java:100)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
      	at org.hibernate.testing.junit4.TestClassMetadata.performCallbackInvocation(TestClassMetadata.java:201)
      

      You can simply reproduce it by changing EntityA to use FetchType.EAGER instead of FetchType.LAZY in your JoinedInheritanceTest like so:

      	// Test entities for metamodel building for HHH-12332
      	@Entity(name = "BaseEntity")
      	@Inheritance(strategy = InheritanceType.JOINED)
      	public static class BaseEntity {
      		@Id
      		private long id;
      	}
      
      	@Entity(name = "EntityA")
      	public static class EntityA extends BaseEntity {
      		@OneToMany(fetch = FetchType.EAGER) //changed from LAZY to EAGER
      		private Set<EntityC> attributes;
      		@ManyToOne(fetch = FetchType.LAZY)
      		private EntityC relation;
      	}
      
      	@Entity(name = "EntityB")
      	public static class EntityB extends BaseEntity {
      		@OneToMany(fetch = FetchType.LAZY)
      		private Set<EntityD> attributes;
      		@ManyToOne(fetch = FetchType.LAZY)
      		private EntityD relation;
      	}
      
      	@Entity(name = "EntityC")
      	public static class EntityC {
      		@Id
      		private long id;
      	}
      
      	@Entity(name = "EntityD")
      	public static class EntityD {
      		@Id
      		private long id;
      	}
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Stride room