반응형
메서드 이름 정리
| 메서드 키워드 | 설명 | SQL 의미 |
| findBy | 조건으로 조회 (리스트/단건 가능) | SELECT * FROM ... WHERE |
| findAllBy | 조건으로 전체 조회 | SELECT * FROM ... WHERE |
| countBy | 조건으로 개수 조회 | SELECT COUNT(*) FROM ... WHERE |
| existsBy | 조건 만족 여부(boolean) | EXISTS (SELECT 1 FROM ... WHERE) |
| deleteBy | 조건으로 삭제 | DELETE FROM ... WHERE |
| readBy / getBy | findBy와 동일 (대체로 잘 안 씀) | same as findBy |
조건연산 키워드
| 키워드 | 예시 메서드 | SQL 의미 |
| LessThan | findByAgeLessThan(int) | < |
| GreaterThan | findByAgeGreaterThan(int) | > |
| Before / After | findByCreatedAtBefore(Date) | 날짜 비교 (<, >) |
| IsNull | findByDeletedAtIsNull() | IS NULL |
| IsNotNull | findByUpdatedAtIsNotNull() | IS NOT NULL |
| Like | findByNameLike(String) | LIKE |
| StartingWith | findByNameStartingWith("홍") | LIKE '홍%' |
| EndingWith | findByNameEndingWith("길") | LIKE '%길' |
| Containing | findByNameContaining("길동") | LIKE '%길동%' |
| In | findByStatusIn(List<Status>) | IN (...) |
| Not | findByNameNot(String) | != |
| IgnoreCase | findByNameIgnoreCase(String) | 대소문자 무시 (LOWER(...)) |
| And | findByNameAndAge(String, int) | AND 조건 |
| Or | findByNameOrAge(String, int) | OR 조건 |
| Between | findByAgeBetween(int, int) | BETWEEN A AND B |
반응형
'🗄️ 백엔드 > 🍃Spring' 카테고리의 다른 글
| # QueryDsl 기본설정 (spring boot 3.x 이상) (0) | 2025.05.28 |
|---|---|
| # Spring - 예외처리 @Valid를 사용해 유효성검사 하기 (1) | 2025.05.27 |
| # QueryDSL 조건절 함수 정리 (0) | 2025.05.19 |
| # 프론트엔드와 백엔드에서 각각 시간 포맷 처리하는 이유 (Spring Boot + JS) (0) | 2025.05.12 |
| # JSP - iframe 외부(부모)에 변수 넘기기 (0) | 2025.03.25 |
