How do you create a Spring JPA repository findBy query using a property that contains a keyword?
To overcome this problem, I've defined the query manually using the @Query
annotation. I'll happily accept anyone else's answer if they find a solution that doesn't require a manual query.
public interface ThingRepository extends JpaRepository<ThingEntity, Long> {
@Query("SELECT t FROM Thing t WHERE t.fooIn = ?1 AND t.bar = ?2")
ThingEntity findByFooInAndBar(String fooIn, String bar);
}
Spring is parsing 'In' in your method to create the query. Check the link for create your query: you should change the name of the variable fooIn
to fooin
or something like that...
- Query creation