Skip to content

Conversation

@cigaly
Copy link
Contributor

@cigaly cigaly commented Dec 18, 2024

Jira issue HHH-18960

Currently when named query parameter allows multiple value binding (like parameters for in), in generated query it is represented as raw type instead of List (or, possibly, Collection). Same problem is present when generating meta model class for Jakarta Data repository.


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.


…e binding, instance of java.util.Collection should be allowed as parameter
…st, Set, or Collection with parameter type as generic type
Copy link
Member

@gavinking gavinking left a comment

Choose a reason for hiding this comment

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

LGTM

@gavinking gavinking merged commit 050089e into hibernate:main Dec 18, 2024
21 of 23 checks passed
@gavinking
Copy link
Member

Merged, thanks so much, @cigaly

@cigaly
Copy link
Contributor Author

cigaly commented Dec 18, 2024

You're welcome!

@cigaly
Copy link
Contributor Author

cigaly commented Dec 19, 2024

@gavinking It seems that this solution can not work properly due to (org.hibernate.query.hql.internal.SemanticQueryBuilder)

	private SqmExpression<?> visitFinalFunctionArgument(ParseTree expression) {
		// the final argument to a function may accept multi-value parameter (varargs),
		// 		but only if we are operating in non-strict JPA mode
		parameterDeclarationContextStack.push( () -> !creationOptions.useStrictJpaCompliance() );
...

So, when useStrictJpaCompliance is set to false (by default), every parameter will allow multi value binding. I'm afraid that this can make more troubles than original problem I've tried to solve :-(

@gavinking
Copy link
Member

Ah okey good, can you send me you test case, please?

@cigaly
Copy link
Contributor Author

cigaly commented Dec 19, 2024

@gavinking Here it is - PR #9475
Simply added named query in existing test case

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