Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RadekHS
Copy link

@RadekHS RadekHS commented Aug 8, 2024

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
Member

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

@RadekHS
Copy link
Author

RadekHS commented Aug 12, 2024

@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