From 6cdb6ce1f954eaca082568a7e14523959fd0dc1b Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Tue, 3 May 2022 16:33:09 -0500 Subject: [PATCH] Workaround to make Contains queries work. 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: https://github.com/spring-projects/spring-data-jpa/issues/2519, https://github.com/spring-projects/spring-data-jpa/issues/2472 See #636. --- jpa/vavr/src/main/java/example/PersonRepository.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jpa/vavr/src/main/java/example/PersonRepository.java b/jpa/vavr/src/main/java/example/PersonRepository.java index f49f32dc..547e841d 100644 --- a/jpa/vavr/src/main/java/example/PersonRepository.java +++ b/jpa/vavr/src/main/java/example/PersonRepository.java @@ -25,6 +25,7 @@ import java.util.List; import java.util.Optional; import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; /** * Repository interface showing the usage of Vavr collections and its {@link Option} type as repository query method @@ -51,7 +52,7 @@ public interface PersonRepository extends Repository { * @param firstname * @return */ - Seq findByFirstnameContaining(String firstname); + Seq findByFirstnameContaining(@Param("firstname") String firstname); /** * Returning a {@link Try} is supported out of the box with all exceptions being handled by {@link Try} immediately. @@ -59,5 +60,5 @@ public interface PersonRepository extends Repository { * @param lastname * @return */ - Try> findByLastnameContaining(String lastname); + Try> findByLastnameContaining(@Param("lastname") String lastname); }