-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Issue with spring-data "startingWith" and hibernate 5.6.7: Parameter value [\] did not match expected type [java.lang.String (n/a)]" with findAllByXXXStartingWith #2472
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
Comments
I have the same problem and i have debugged with different versions of hibernate. It works fine in hibernate 5.6.5 but fails in 5.6.6 or later. Here is a minimal reproducer project: demo.zip As you can see the code runs fine on the first call but on the second call it fails. So there seems to be some caching issue somewhere.
The generated JPQL looks like this
For all subsequent calls. Notice the escape :param0
|
We faced the same problem updating spring boot to 2.6.5 where the updated version of hibernate is used by default. Additionally we observed the problem with contains, startsWith and EqualsIgnoreCase as well. |
This seems to be a Hibernate problem. |
I'd greatly appreciate if someone could help me promote the fix: hibernate/hibernate-orm#4918. |
A workaround would be to explicitly add |
Another workaround seems to set the hibernate version (in Spring Boot´s pom.xml file) back to a working one: |
workaround is fine ... but why depending on a buggy hibernate version when everyone updates spring boot to 2.6.6 because of vulnerabilty issues ... <:o( |
This is fixed in Hibernate 5.6.9 (according to https://hibernate.atlassian.net/browse/HHH-15142) |
I got same issue but i resolve it by implementing the JPQL and did not use the 'startwith' function. Below is the example query |
Still have the issue with Spring Boot 2.6.7 |
2 similar comments
With gradle, just do this: `implementation 'org.hibernate:hibernate-core:5.6.5.Final' Should work with any spring (boot) version. |
use spring boot 2.6.2 version |
The project I am working is not using Spring boot, plus I do not want to downgrade my version of hibernate core. |
Workaround is to either pin Hibernate to an older, working version: <properties>
<hibernate.version>5.6.5.Final</hibernate.version>
</properties> ...or if you don't want to go to an older version of Hibernate, to parameterize your repository... @Repository
public interface BookRepository extends JpaRepository<Book, String> {
List<Book> findByIsbnContaining(@Param("isbn") String isbn);
} This forces query derivation to plugin the "right" parameter and hence not break at the Entity Manager. |
Follow #2519. |
Due to a bug in Hibernate (https://hibernate.atlassian.net/browse/HHH-15142), any Like-based custom finder will fail when submitted to the Entity Manager a second time. This patch includes a workaround until Hibernate 5.6.9.Final is released. See also: spring-projects/spring-data-jpa#2519, spring-projects/spring-data-jpa#2472 See #636.
5.6.9 version does not seem to resolve this problem... |
Sprint Boot 2.6.8 fixes the issue! |
Due to a bug in Hibernate (https://hibernate.atlassian.net/browse/HHH-15142), any Like-based custom finder will fail when submitted to the Entity Manager a second time. This patch includes a workaround until Hibernate 5.6.9.Final is released. See also: spring-projects/spring-data-jpa#2519, spring-projects/spring-data-jpa#2472 See #636.
쿼리스트링으로 전달된 검색 조건, 키워드를 기반으로 관리자 데이터를 조회함 하이버네이트 버그로 같은 URL 두번 요청 실패 발생, 하이버네이트 버전 변경 spring-projects/spring-data-jpa#2472
peg implementation 'org.hibernate:hibernate-core:5.6.5.Final'
The hibernate-orm tools cannot report problems in github. They are inefficient! They generate documentation and examples of DAOs. At present, it can only run normally under the ant plug-in and the corresponding life cyclerun. The hibernate tools maven cannot configure the DAO location, which is very difficult to use. And they are changing their name (jakarta). God. A bunch of bugs |
create a repository method using the Query annotation for your signature |
- Hibernate 버전 문제를 해결하기 위해 build.gradle 수정 (버전 5.6.5.Final로 다운그레이드) - 오류 관련 URL spring-projects/spring-data-jpa#2472
Hello,
I am trying to fetch some entity using a “find all by property starting with” query which amount to a CriteriaQuery using javax.persistence.criteria.CriteriaBuilder.like(Expression, String, char)
When migrating to hibernate-entitymanager 5.6.7.Final I do have this error:
It seems to happens when invoking twice the same method (in the attached demo_spring-data-2.6.3_hibernate_5.6.7..zip,
findByLastNameStartingWith
):In the first invocation, we can see the validate (
org.hibernate.query.spi.QueryParameterBindingValidator.validate(Type, Object, TemporalType)
) takes the following arguments set:In the second case:
The demo (was generated using Spring Initializer and this doc: https://www.baeldung.com/spring-data-jpa-query: demo_spring-data-2.6.3_hibernate_5.6.7..zip. It can be imported as Maven project in Eclipse and IntelliJ.
Note: I did try using
CriteriaQuery
as shown below and got no error and that's why I created issue here instead of hibernate, since I'm not sure where the problem might be (I would say that it is in Hibernate but given the example below works, there might be more to it):Versions information:
The text was updated successfully, but these errors were encountered: