Query methods in multiple fields in spring JPA - SoftLabio

Ads Here

Monday, September 9, 2019

Query methods in multiple fields in spring JPA



In this tutorial I am going to show you some query methods in spring JPA. Based on those custom methods spring resolves those methods into actual SQL statements. In this tutorial I am using a custom Student data type. So we can write those codes in a Spring repository interface.

public interface StudentRepository extends CrudRepository<Student, Long> {

    List<Student> findByRollAndName(Integer roll, String name);

    List<Student> findByNameOrAge(String name, Integer age);

    List<Student> findByNameOrAge(String name, Integer age);

    List<Student> findByAgeAndHeight(Integer age, double height);

    List<Student>findByNameIgnoreCaseAndMark(String name, String mark);

    List<Student> findByNameIgnoreCaseAndMark(String name, String mark);

    List<Student> findByAgeAndNameAndMark(Integer age, String name, String mark);

    List<Student> findByAgeAndNameAndMark(Integer age, String name, String mark);

}




No comments:

Post a Comment