-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
hibernate-core/src/main/java/org/hibernate/jpa/spi/NativeQueryArrayTransformer.java
Show resolved
Hide resolved
LGTM. One suggestion. |
There was a problem hiding this 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.
Oh, oops, I did not notice that. |
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 |
No need for the |
Ok, I will check it out! |
@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 edit: actually I just checked h2 but there seems to be other problems in some other jobs, I will check them out. |
That goal doesn't run check style, only spotless and our custom
A lot of DBs complaining about the native query format. Maybe let's just use a |
yep and some dbs seem not to like a simple
if that's ok for you, then I suspect it's going to be the best here.
ok, that's why, thx! |
@mbladel I must be doing something wrong because whatever I try, I can't run checkstyleMain, I get:
And if I run |
Ah, I was working on the PR for the main branch, and there it seems there is no |
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. |
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 insideJdbcSelectExecutorStandardImpl
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