Skip to content

QueryDsl 적용

Robin Choi edited this page Apr 6, 2022 · 6 revisions

#1. 도입 이유 Spring Data Jpa를 사용하게 되면 save, find와 같은 주요 메서드는 제공해주지만 커스텀이 필요한 메소드의 경우, @Query어노테이션을 사용한 JPQL을 사용한다. JPQL의 경우,

@Query(value = "select p " +
            "from Post p join p.account left join p.postLike" +
            "where p.account.id = :accountId and p. " +
            "AND DATE(n.regDate) = :targetDate " +
            "ORDER BY n.no")
    public List<SelectAllNaver> findAllByDate(@Param("date") Date date,
                                              @Param("targetDate") Date targetDate,
                                              Pageable limitOneHundred);
Clone this wiki locally