10000 HHH-19472: native queries can return Object[] by victornoel · Pull Request #10177 · hibernate/hibernate-orm · GitHub
[go: up one dir, main page]

Skip to content

HHH-19472: native queries can return Object[] #10177

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 20, 2025

Conversation

victornoel
Copy link
Contributor
@victornoel victornoel commented May 19, 2025

The fix is quite simple and obvious. I also refactored the test that was previously introduced for HHH-18450 to cover more cases and make it easier to maintain.

My understanding is that when executing queries (any kind), we either provide a row transformer, a tuple transformer or the expected result class. Sqm-based queries are providing the row transformer directly (based on the result class) while native queries are currently implemented with providing directly the tuple transformer.

So I went with fitting in the existing code by supporting Object[] at the tuple transformer level for native queries.

Alternatively I looked into producing a row transformer in NativeSelectQueryPlanImpl or moving all the default row transformer instantiation (that can be found in a few places of the codebase, e.g., ConcreteSqmSelectQueryPlan#determineRowTransformer) directly inside JdbcSelectExecutorStandardImpl to reduce code duplication and align behaviours but it was way too much work and I worried to introduce regressions.

I will also provide a PR for the main branch once the current implementation here is confirmed as being the right approach.


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-19472

@gavinking
Copy link
Member

LGTM. One suggestion.

Copy link
Member
@mbladel mbladel left a comment

Choose a reason for hiding this comment

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

Thanks @victornoel, this looks great. Please open a PR against main, we usually push changes there and back-port a selection of those to maintenance branches.

@gavinking
Copy link
Member

Please open a PR against main, we usually push changes there and back-port a selection of those to maintenance branches.

Oh, oops, I did not notice that.

@victornoel
Copy link
Contributor Author

Thanks @victornoel, this looks great. Please open a PR against main, we usually push changes there and back-port a selection of those to maintenance branches.

Right, then here it is: #10178

Feel free to close this PR if it fits your process or tell me if I should apply the @since change here too instead?

@mbladel
Copy link
Member
mbladel commented May 19, 2025

Feel free to close this PR if it fits your process or tell me if I should apply the @since change here too instead?

No need for the @since here. CI isn't very happy about the new tests though it seems.

@victornoel
Copy link
Contributor Author

Feel free to close this PR if it fits your process or tell me if I should apply the @since change here too instead?

No need for the @since here. CI isn't very happy about the new tests though it seems.

Ok, I will check it out!

@victornoel
Copy link
Contributor Author
victornoel commented May 19, 2025

@mbladel I'm a bit lost about the errors I'm seeing: it seems to be about checkstyle but it's only for a subset of the CI jobs. When I run JAVA_HOME=/usr/lib/jvm/java-17-openjdk ../gradlew formatChecks in hibernate-core folder, everything seems ok.

edit: actually I just checked h2 but there seems to be other problems in some other jobs, I will check them out.

@mbladel
Copy link
Member
mbladel commented May 19, 2025

@mbladel I'm a bit lost about the errors I'm seeing: it seems to be about checkstyle but it's only for a subset of the CI jobs. When I run JAVA_HOME=/usr/lib/jvm/java-17-openjdk ../gradlew formatChecks in hibernate-core folder, everything seems ok.

That goal doesn't run check style, only spotless and our custom enforceRules task. You can run checkstyleMain or just a full check.

edit: actually I just checked h2 but there seems to be other problems in some other jobs, I will check them out.

A lot of DBs complaining about the native query format. Maybe let's just use a @RequiresDialect(H2Dialect.class) as we're not really trying to test cross-database functionalities here.

@victornoel
Copy link
Contributor Author

A lot of DBs complaining about the native query format.

yep and some dbs seem not to like a simple select 1, I guess they expect a FROM.

Maybe let's just use a @RequiresDialect(H2Dialect.class) as we're not really trying to test cross-database functionalities here.

if that's ok for you, then I suspect it's going to be the best here.

That goal doesn't run check style, only spotless and our custom enforceRules task. You can run checkstyleMain or just a full check.

ok, that's why, thx!

@victornoel
Copy link
Contributor Author

@mbladel I must be doing something wrong because whatever I try, I can't run checkstyleMain, I get:

Task 'checkstyleMain' not found in root project 'hibernate-orm' and its subprojects.

And if I run check, then everything passes.

@victornoel
Copy link
Contributor Author

Ah, I was working on the PR for the main branch, and there it seems there is no checkstyleMain while on 6.6 there is, that's why!

@mbladel
Copy link
Member
mbladel commented May 20, 2025

The fix is merged on main. We'll merge this too once we have a few other back ports for the next 6.6 maintenance release.

@mbladel mbladel added the 6.6 label May 20, 2025
@mbladel mbladel merged commit 0a0e3a4 into hibernate:6.6 May 20, 2025
21 of 25 checks passed
@victornoel victornoel deleted the HHH-19472 branch May 20, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0