오답노트
[Spring JPA] Query Method 본문
Query Method
JPA에서 쿼리문을 직접 작성하지 않고 Method명으로 지정만 하면 자동으로 쿼리를 만들고 요청까지 해주는 편리한 기능이 있다.
https://www.javaguides.net/2018/11/spring-data-jpa-query-creation-from-method-names.html
public interface UserRepository extends JpaRepository<User, Long> {
List<User> findByName(String name);
User findByEmail(String email);
User getByEmail(String email);
User readByEmail(String email);
User queryByEmail(String email);
User searchByEmail(String email);
User streamByEmail(String email);
User findUserByEmail(String email);
List<User> findByEmailAndName(String email, String name);
List<User> findByIdAfter(Long id);
List<User> findByAddressListIsNotEmpty();
List<User> findByNameIn(List<String> names);
List<User> findTop1ByName(String name);
List<User> findTopByNameOrderByIdDesc(String name);
Page<User> findByName(String Name, Pageable pageable);
}
'Java > Spring' 카테고리의 다른 글
[Spring JPA] 영속성 전이(Cascade) 와 고아제거속성(orphanRemoval) (0) | 2023.07.24 |
---|---|
[Spring JPA] Entity Relations (0) | 2023.07.19 |
[Spring JPA] Auditing (0) | 2023.07.19 |
[Spring JPA] H2 In-Memory DB (0) | 2023.07.18 |
[Spring] 코드 Test하기 (0) | 2023.07.17 |