스프링 부트 (SpringBoot)

Querydsl 개념과 신텍스

종우공간 2021. 7. 14. 05:44

규모가 있는 프로젝트에서의 데이터 조회는 FK의 조인, 복잡한 조건 등으로 인해 이런 Entity 클래스만으로 처리하기 어려워 조회용 프레임워크를 추가로 사용한다. 대표적인 예로, querydsl, jooq, MyBatis 등이 있다. 조회는 위 세가지 프레임워크 중 하나를 통해 조회하고, 등록/수정/삭제 등은 SpringDataJpa를 통해 진행한다. 

 

Querydsl을 추천하는 세가지 이유?

- 타입 안정성이 보장된다.

- 국내 많은 회사가 사용중이다.

- 래퍼런스가 많다.

 

@Query("SELECT p FROM Posts p ORDER BY p.id DESC"); SQL ORDER BY keyword

- The ORDER BY keyword is used to sort the result-set in ascending or descending order

- The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

- Syntax: SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC;