[JIRA] (HHH-16532) Hibernate entity with @Any attribute throws a nullpointer exception when merging
by Vincent Bouthinon (JIRA)
Vincent Bouthinon ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNTcwYmY1ZDg3... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-16532?atlOrigin=eyJpIjoiNTcwYm... ) HHH-16532 ( https://hibernate.atlassian.net/browse/HHH-16532?atlOrigin=eyJpIjoiNTcwYm... ) Hibernate entity with @Any attribute throws a nullpointer exception when merging ( https://hibernate.atlassian.net/browse/HHH-16532?atlOrigin=eyJpIjoiNTcwYm... )
Issue Type: Bug Affects Versions: 6.2.0.CR3 Assignee: Unassigned Components: hibernate-core Created: 28/Apr/2023 02:54 AM Priority: Major Reporter: Vincent Bouthinon ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=70121%3... )
Hi,
I opened a post on the forum org.hibernate.sql.results.graph.Fetchable.asAttributeMapping()" is null - Hibernate ORM - Hibernate ( https://discourse.hibernate.org/t/org-hibernate-sql-results-graph-fetchab... )
The following problem appears when doing a merge of an entity that has an @Any attribute :
java.lang.NullPointerException: Cannot invoke "org.hibernate.metamodel.mapping.AttributeMapping.getAttributeMetadata()" because the return value of "org.hibernate.sql.results.graph.Fetchable.asAttributeMapping()" is null
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$createFetchableBiConsumer$3(LoaderSelectBuilder.java:767)
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.visitFetches(LoaderSelectBuilder.java:677)
at org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:124)
at org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationMapping$AnyValuedResultGraphNode.afterInitialize(DiscriminatedAssociationMapping.java:439)
at org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationMapping$AnyValuedFetch.<init>(DiscriminatedAssociationMapping.java:558)
at org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationMapping.generateFetch(DiscriminatedAssociationMapping.java:396)
at org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping.generateFetch(DiscriminatedAssociationAttributeMapping.java:138)
at org.hibernate.sql.results.graph.FetchParent.generateFetchableFetch(FetchParent.java:108)
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.lambda$createFetchableBiConsumer$3(LoaderSelectBuilder.java:840)
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.visitFetches(LoaderSelectBuilder.java:677)
at org.hibernate.loader.ast.internal.LoaderSqlAstCreationState.visitFetches(LoaderSqlAstCreationState.java:124)
at org.hibernate.sql.results.graph.AbstractFetchParent.afterInitialize(AbstractFetchParent.java:32)
at org.hibernate.sql.results.graph.entity.AbstractEntityResultGraphNode.afterInitialize(AbstractEntityResultGraphNode.java:80)
at org.hibernate.persister.entity.AbstractEntityPersister.createDomainResult(AbstractEntityPersister.java:1221)
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.generateSelect(LoaderSelectBuilder.java:446)
at org.hibernate.loader.ast.internal.LoaderSelectBuilder.createSelect(LoaderSelectBuilder.java:174)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.createLoadPlan(SingleIdEntityLoaderStandardImpl.java:180)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.resolveLoadPlan(SingleIdEntityLoaderStandardImpl.java:120)
at org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl.load(SingleIdEntityLoaderStandardImpl.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:3519)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3509)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:602)
at com.efluid.hibernate.listener.EfluidLoadEventListener.loadFromDatasource(EfluidLoadEventListener.java:28)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromCacheOrDatasource(DefaultLoadEventListener.java:588)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:557)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:550)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:202)
at org.hibernate.event.internal.DefaultLoadEventListener.loadWithRegularProxy(DefaultLoadEventListener.java:282)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:237)
at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:106)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:78)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:138)
at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1231)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1219)
at org.hibernate.loader.internal.IdentifierLoadAccessImpl.doLoad(IdentifierLoadAccessImpl.java:194)
at org.hibernate.loader.internal.IdentifierLoadAccessImpl.lambda$load$1(IdentifierLoadAccessImpl.java:160)
at org.hibernate.loader.internal.IdentifierLoadAccessImpl.perform(IdentifierLoadAccessImpl.java:107)
at org.hibernate.loader.internal.IdentifierLoadAccessImpl.load(IdentifierLoadAccessImpl.java:160)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:1024)
at org.hibernate.event.internal.DefaultMergeEventListener.lambda$entityIsDetached$0(DefaultMergeEventListener.java:321)
at org.hibernate.engine.spi.LoadQueryInfluencers.fromInternalFetchProfile(LoadQueryInfluencers.java:79)
at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:319)
at org.hibernate.event.internal.DefaultMergeEventListener.merge(DefaultMergeEventListener.java:150)
at org.hibernate.event.internal.DefaultMergeEventListener.doMerge(DefaultMergeEventListener.java:143)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:127)
at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:81)
at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:848)
at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:834)
I will do a PR for a test case reproducer.
Thank you in advance
( https://hibernate.atlassian.net/browse/HHH-16532#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-16532#add-comment?atlOrigin=ey... )
Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.... ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100223- sha1:3b773b8 )