Skip to content

HHH-19490 Fix NPE when using array_position on sql array type #10229

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

chanzxxx
Copy link
Contributor

@chanzxxx chanzxxx commented May 27, 2025

NPE occurs when using array_position function.

Query

select testEntity from TestEntity testEntity where ARRAY_POSITION(testEntity.values, ?1) IS NOT NULL

Error

Cannot invoke "org.hibernate.query.sqm.SqmBindableType.getSqmType()" because the return value of "org.hibernate.query.sqm.tree.SqmTypedNode.getExpressible()" is null

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.


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

Copy link
Member

@mbellade mbellade left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chanzxxx! I left a few minor comments but overall your approach looks good.

@chanzxxx
Copy link
Contributor Author

Thanks @chanzxxx! I left a few minor comments but overall your approach looks good.

Good points @mbladel ! I just applied your feedbacks to PR.

@mbellade
Copy link
Member

I took the liberty of squashing the commits and fixing a small implementation detail for hsqldb that caused the test to fail (it requires a cast for parameters). While I was at it I also moved the test within the ArrayPositionTest class at it and created a similar one for ArrayPositionsTest.

Thanks again for the contribution!

@mbellade mbellade merged commit 47f4af9 into hibernate:main May 28, 2025
23 of 24 checks passed
@chanzxxx
Copy link
Contributor Author

@mbladel It was a pleasure to contribute. 😀 Thanks for quick response!

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