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.
This commit is contained in:
Greg L. Turnquist
2022-05-03 16:33:09 -05:00
parent 586092a287
commit 6cdb6ce1f9

View File

@@ -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<Person, Long> {
* @param firstname
* @return
*/
Seq<Person> findByFirstnameContaining(String firstname);
Seq<Person> 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<Person, Long> {
* @param lastname
* @return
*/
Try<Option<Person>> findByLastnameContaining(String lastname);
Try<Option<Person>> findByLastnameContaining(@Param("lastname") String lastname);
}