-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Just 1st call works for findByXContainingOrYContainingOrderByY #2512
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
Thanks for the report. We've seen this issue also in other places (e.g. Spring Data Examples) and need to fix it. |
I don't think this is related to the Spring Data Example issue mentioned earlier. I wrote a test case inside your project @ivangfr and got it to fail directly invoking the repository on the second call. Only when I dropped the @SpringBootTest
class BookApiApplicationTests {
private static final String ISBN = "9781603090773";
@Autowired BookRepository repository;
@Test
void repositoryQuery() {
List<Book> books = repository.findByIsbnOrTitleOrderByTitle(ISBN, ISBN);
assertThat(books).hasSize(1);
assertThat(books.get(0).getIsbn()).isEqualTo("9781603090773");
System.out.println(books.get(0));
List<Book> books2 = repository.findByIsbnOrTitleOrderByTitle(ISBN, ISBN);
assertThat(books2).hasSize(1);
assertThat(books2.get(0).getIsbn()).isEqualTo("9781603090773");
System.out.println(books2.get(0));
}
} This makes no sense. I'm going to do some more digging to see if this fails on other versions of Spring Boot, and try to isolate what it happening. |
Duplicates #2472 (a Hibernate issue). It happens when you have a criteria-like structure submitted more than once to the Entity Manager. Fixed in Hibernate 5.6.9.Final (not yet released) tracking https://hibernate.atlassian.net/browse/HHH-15142. 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 paramaterize your repository... @Repository
public interface BookRepository extends JpaRepository<Book, String> {
List<Book> findAllByOrderByTitle();
List<Book> findByIsbnContainingOrTitleContainingOrderByTitle(@Param("isbn") String isbn,
@Param("title") String title);
} This forces query derivation to plugin the "right" parameter and hence not break at the Entity Manager. |
Track #2519. |
Hi, I have a project called
springboot-react-basic-auth
that uses spring-data-jpa. The spring-boot version is2.6.7
.In this project, I have a the following Query Method defined in the Repository class:
However, there is a problem with
findByIsbnContainingOrTitleContainingOrderByTitle
.Let's say that the app has just started. The query just works for the 1st request. Subsequent requests fail with the following exception
How to reproduce
The text was updated successfully, but these errors were encountered: