How to check if a row with a specific column value exists in Spring Data

Spring Data has a great declarative way of defining queries, called derived queries. Suppose you have a Person class with an email field. Then you can define the following method in a Repository interface: public interface PersonRepository extends JpaRepository<Person,Long>{ List<Person> findByEmail(String email); } Spring derives the query based on the method name, in this case a query to retrieve all persons with a given value for the email field. As you can see, the method returns a List....

June 11, 2019 ยท 2 min