-
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
QueryEnhancer.hasConstructorExpression()
returns false
for some_function(…) IS TRUE
#3628
Comments
I'm not able to reproduce the issue. Care to provide a reproducer? |
OK, This repository has reproduced the issue: |
I found this: public interface RoleTmplRepository extends CrudRepository<RoleTmpl, Integer> {
/**
* invoking this method, a ConverterNotFoundException will be thrown.
*/
@Query("""
select new bp.web.user.model.RolePart(id, name, rkey) from RoleTmpl
where find_in_set(:appId, appIds) is true and id not in (:idList) and deleted = false
""")
List<RolePart> findRoleInfoListByIdNotInAndAppId(List<Integer> idList, int appId);
/**
* not using 'new bp.web.user.model.RolePart(id, name, rkey)' in sql, it works.
*/
@Query("""
from RoleTmpl
where find_in_set(:appId, appIds) is true and id not in (:idList) and deleted = false
""")
List<RoleTmpl> findAllByIdNotInAndAppId(List<Integer> idList, int appId);
/**
* not using find_in_set in sql, it works too.
*/
@Query("""
select new bp.web.user.model.RolePart(id, name, rkey) from RoleTmpl
where id not in (:idList) and deleted = false
""")
List<RolePart> findRoleInfoListByIdNotIn(List<Integer> idList);
} |
I found through debugging that the root cause of this issue is that Line 2:34 mismatched input 'is' expecting {',', ')', '+', '-', '/', '||', '[', '.', '*', BY, DAY, EPOCH, HOUR, MINUTE, MONTH, NANOSECOND, QUARTER, SECOND, WEEK, YEAR}; Bad JPQL grammar [select new bp.web.user.model.RolePart(id, name, rkey) from RoleTmpl
where find_in_set(:appId, appIds) is true and id not in (:idList) and deleted = false
] Is there really a syntax error in the HQL I wrote, and how should I correct it? select new bp.web.user.model.RolePart(id, name, rkey) from RoleTmpl
where find_in_set(:appId, appIds) is true and id not in (:idList) and deleted = false |
I try to replace org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.lang.Object' with right expression of type 'java.lang.Boolean' I try to replace org.hibernate.query.SemanticException: Cannot compare left expression of type 'java.lang.Object' with right expression of type 'java.lang.Integer' I try to remove org.hibernate.query.SemanticException: Non-boolean expression used in predicate context: find_in_set(:appId,appIds) [select new bp.web.user.model.RolePart(id, name, rkey) from RoleTmpl |
Thanks for further analysis, we need to fix:
|
QueryEnhancer.hasConstructorExpression()
returns false
for some_function(…) IS TRUE
Thanks a lot for digging a bit more and providing details. I was able to reproduce the issue with the code you've provided. We're missing support not only for |
Very good! Also, there is a swallowing exception code in |
We decided to keep the exception handling. We still might have users that use HQL grammar that our parser doesn't recognize. In cases there is no projection ongoing, parsing the query might fail on our side while the actual query is valid. We do not want to prevent that kind of applications from running by introducing a change in a bugfix release. We decided to not catch that exception in the next feature release. One more thing: Please refrain from attaching images with code to tickets. Instead, use regular links or copy code into the comment as images cannot be indexed for search. |
Ok, I got it. |
When I upgraded SpringBoot from
v2.7.18
to3.3.4
, Jpa encountered an error :ConverterNotFoundException
throwed when invoking thefindRoleInfoListByIdNotInAndAppId
methodThe text was updated successfully, but these errors were encountered: