230302 TIL

William Parker·2023년 3월 2일

Error : An error occurs when paging and join fecth are used together in JPQL.

	@Query(value = "select bd from BlacklistDemand bd join fetch bd.user where bd.status = :status")
	Page<BlacklistDemand> findAllByStatus(@Param("status") AcceptedStatusEnum status, Pageable pageable);

Answer :

If the version changes, it is changed to use the count query together, so the count query is specified separately.

	@Query(value = "select bd from BlacklistDemand bd join fetch bd.user where bd.status = :status", countQuery = "select count(b) from BlacklistDemand b where b.status=:status")
	Page<BlacklistDemand> findAllByStatus(@Param("status") AcceptedStatusEnum status, Pageable pageable);
profile
Developer who does not give up and keeps on going.

0개의 댓글