-
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
ConverterNotFoundException exception in hql spring-data-jpa-3.1.0 #2990
Comments
Last I checked, DTO via construction in the query requires a FQDN class definition. Does your POJO definition really NOT have a package declaration? If so, I'd recommend testing out if putting it into a package and then putting that into the query resolves the issue. I've also run this query through the HQL parser, and our parser has no issue with the You may also want to turn on Hibernate logging to see more of what's happening as well. |
Yes indeed, i just put pojo in the example for the sake of simplicity. The actual code of course contains a fully qualified name. I can update the code snippet but this is not the issue. After some debugging it seems that the query executes successfully and correct results are returned. It seems that the error is in the result processing. |
Can you post your repository definition along with the domain definition? |
Repository:
Domain:
|
I can't see anything obvious in the code listings you have provided. Is there perhaps some way to build a reproducer, staged on github, ideally using https://start.spring.io, H2 (or Testcontainers for PostGreSQL, etc.), and the version of Spring Boot aligned with your issue? |
spring boot version is 3.1.0. I will try to find some time to implement a test project |
created a test project that reproduces the error in https://github.com/teopapath/spring-boot-error. Changing the spring-boot version makes the test successful. |
Simply switching from: @Transactional(readOnly = true)
@Query(name = Authority.NAMED_QUERY_FIND_NON_PENDING_AUTHORITY_ROLE_LIST)
List<AuthorityRoleDTO> findNonPendingAuthorityRoleList(); to @Transactional(readOnly = true)
@Query("select new com.example.demo.AuthorityRoleDTO("
+ "au.userId, au.status, r.name, r.code, au.creationDate) "
+ "from Authority au "
+ "join Role r on r.code = au.code "
+ "where au.status <> 'PENDING' ")
List<AuthorityRoleDTO> findNonPendingAuthorityRoleList(); seems to solve the problem and make the test go green. So apparently the issue has to do with named queries vs. directly provided ones. |
We have tons of such queries in our application and is impossible to test them (or change) all. Will a fix be provided for this? |
@teopapath Sorry, I wasn't suggesting that you alter your app. I'm simply tracking that this might be where the discrepancy lies. I'm trying to track down precisely where it diverges. |
I figured it out. It's a little pesky. You see the
This taps into Hibernate directly, asking for the query. Apparently Hibernate when parsing:
...transforms However, in Spring Data JPA 3.1.0 (part of Spring Boot 3.1.0), we didn't have proper support for This was patched with #2970 via 6d56a25. The good news is that this Friday, there is a service release scheduled for Spring Data
...and pick up that patch. You can also choose to wait until the 22nd for Spring Boot's scheduled release of 3.1.1, which should pick up Spring Data's service release. Or you can choose to jump to snapshots, as you've already seen. Since this issue simply duplicates #2970, I'm going to close it. |
@gregturn it seems that the issue still exists in 3.1.2. Test case can be found in error2990_2. Still works in 3.0.x release. Opened #3085 for this |
Well, the scenario this ticket as closed against was lack of support for The other scenario where the |
I have a NamedQuery like:
When query is executed a ConverterNotFoundException is thrown.
If i change the query to
everything works as expected.
It seems that there is a problem in parsing this part: and au.status <> 'PENDING'
The same query was executing successfully in spring-boot 3.0.7
Stacktrace:
The text was updated successfully, but these errors were encountered: