Skip to content

HHH-20782 Fix NPE for @FilterJoinTable and @ManyToMany in HQL joins - #13210

Open
rafalsbs wants to merge 1 commit into
hibernate:mainfrom
rafalsbs:HHH-20782-fix-main
Open

HHH-20782 Fix NPE for @FilterJoinTable and @ManyToMany in HQL joins#13210
rafalsbs wants to merge 1 commit into
hibernate:mainfrom
rafalsbs:HHH-20782-fix-main

Conversation

@rafalsbs

@rafalsbs rafalsbs commented Aug 18, 2026

Copy link
Copy Markdown

HHH-20782

Forward-port of the 7.4 fix for HHH-20782.

A NullPointerException is thrown during SQL AST conversion / filter handling when enabled filters are applied to join-table restrictions for explicit HQL joins.

Affects:

  • 7.4.5.Final and later

Expected behavior:

  • Enabled filters should be applied correctly to join-table restrictions for explicit HQL joins.

Reproducer:

  • Standalone JUnit test using H2 with:
  • GroupEntity using @FilterDef and @FilterJoinTable
  • UserEntity with groups
  • GroupEntity with many-to-many masters association

Fails before fix:

  • from UserEntity u join u.groups g order by g.id
  • from UserEntity u join u.groups g join g.masters m order by m.id

Works:

  • from GroupEntity g order by g.id
  • from UserEntity u order by u.id

Fix:

  • Added the missing null check during filter handling for explicit HQL joins to avoid the NullPointerException during SQL AST conversion.
  • Added regression tests covering the failing scenarios.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.



Please make sure that the following tasks are completed:
Tasks specific to HHH-20782 (Bug):

  • Add test reproducing the bug
  • Add entries as relevant to migration-guide.adoc OR check there are no breaking changes

https://hibernate.atlassian.net/browse/HHH-20782

Fix a NullPointerException thrown during SQL AST conversion/filter
handling when using @FilterJoinTable on many-to-many associations with
explicit HQL join.
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.

1 participant