Skip to content

HHH-18469 Bug reproduction - java.lang.AssertionError - #413

Open
RadekHS wants to merge 3 commits into
hibernate:mainfrom
RadekHS:bug/assertion-error-on-fetch-join
Open

HHH-18469 Bug reproduction - java.lang.AssertionError#413
RadekHS wants to merge 3 commits into
hibernate:mainfrom
RadekHS:bug/assertion-error-on-fetch-join

Conversation

@RadekHS

@RadekHS RadekHS commented Aug 8, 2024

Copy link
Copy Markdown

Jira card: HHH-18469

Description

When migrating to fresh hibernate, some of our queries stopped working, resulting in the following stack trace:

java.lang.AssertionError
	at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.createTableGroupJoin(ToOneAttributeMapping.java:1985)
	at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.createTableGroupForDelayedFetch(ToOneAttributeMapping.java:1806)
	at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.createCircularBiDirectionalFetch(ToOneAttributeMapping.java:1345)
	at org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping.resolveCircularFetch(ToOneAttributeMapping.java:1024)
[...]

The issue is not resolved by HHH-18086, which I tested by a fresh SNAPSHOT version of the library.

Bug description

I found out the issue in the Hibernate's fetch builder logic.

  • In case of having the following entities: A, B1, B2, C, where B1, and B2 refer to the same table.
  • Also, having a mapping A.b, and C.b, and the following SQL:
Select a from A a
LEFT JOIN FETCH a.b b
LEFT JOIN FETCH b.c c
  • The issue occurs. This can be fixed by renaming the mapping, for example from: A.b to A.b1

Work a round

Changing entity's A field b name to any name that differs from entity's C field b. It works both ways - changing entity's C field b name also works.

@yrodiere

Copy link
Copy Markdown
Member

@RadekHS Thanks for the reproducer, but can you please add a link to your new Jira issue in the PR description?

@RadekHS

RadekHS commented Aug 12, 2024

Copy link
Copy Markdown
Author

@yrodiere Thank you :) Done!

@yrodiere yrodiere changed the title Bug reproduction - java.lang.AssertionError HHH-18469 Bug reproduction - java.lang.AssertionError Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants