-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Native query projection with records fail with ConverterNotFoundException
#2757
Comments
This should work if you define the proper Reproducer can be found here: https://github.com/schauder/issue-jpa-2757-sqlresultmapping I guess the problem is that we ask for a |
It would be even better if it could work without How about using |
While certainly possible, I'd vote against it in the general case. In Spring Data JPA, JPA does the mapping. If Spring Data starts to create DTOs you'll end up with a mixture of JPA mapping and Spring Data mapping, which is going to cause a lot of trouble. One variant we could consider I guess, if we could create a |
As far as I understand, the mapping of projections (from e.g. native query results) to interface proxies is not a JPA feature but a Spring Data feature. And it's the The way I understand the issue is that it would feel more natural in today's Java if I could use records for the results of projections instead of interface proxies. Where the interface definitions are scanned for properties according to bean naming conventions of accessors, I could now consider the Are there plans to add something like a |
ConverterNotFoundException
For records, that map cleanly to the given query, it is possible to make these work by providing the target type to |
We now provide the target type to createNativeQuery(…) if we detect that a native query result type is a projection and not an interface. Closes #2757
Refine projection documentation. See #2757
Refine projection documentation. See #2757
Disable records projection test with Hibernate 6.2. See #2757
Disable records projection test with Hibernate 6.2. See #2757
If the
@Query
is native, the results can only be projected with an interface.Unlike jpa queries, there is not room for
select new MyProjection(...
. whereMyProjection
would be arecord
Any chance to see support for record for native queries ?
Something like:
interface based projection are a little bit less expressive and cannot be used in Thymeleaf template engine, which does not like proxies.
Don't you think that
should work ?
The text was updated successfully, but these errors were encountered: