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);
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)