diff --git a/src/main/java/com/funeat/review/specification/SortingReviewSpecification.java b/src/main/java/com/funeat/review/specification/SortingReviewSpecification.java index bae0cb2e..5aa99592 100644 --- a/src/main/java/com/funeat/review/specification/SortingReviewSpecification.java +++ b/src/main/java/com/funeat/review/specification/SortingReviewSpecification.java @@ -87,7 +87,8 @@ private static Predicate checkEquals(final String fieldName, if (LOCALDATETIME_TYPE_INCLUDE.contains(fieldName)) { final Path createdAtPath = root.get(fieldName); final LocalDateTime lastReviewCreatedAt = lastReview.getCreatedAt(); - return criteriaBuilder.equal(createdAtPath, lastReviewCreatedAt); + final int reformatNano = Math.round((float) lastReviewCreatedAt.getNano() / 1000) * 1000; + return criteriaBuilder.equal(createdAtPath, lastReviewCreatedAt.withNano(reformatNano)); } if (LONG_TYPE_INCLUDE.contains(fieldName)) { final Path reviewPath = root.get(fieldName); @@ -120,7 +121,8 @@ private static Predicate checkGreaterThan(final String fieldName, final Review l if (LOCALDATETIME_TYPE_INCLUDE.contains(fieldName)) { final Path createdAtPath = root.get(fieldName); final LocalDateTime lastReviewCreatedAt = lastReview.getCreatedAt(); - return criteriaBuilder.greaterThan(createdAtPath, lastReviewCreatedAt); + final int reformatNano = Math.round((float) lastReviewCreatedAt.getNano() / 1000) * 1000; + return criteriaBuilder.greaterThan(createdAtPath, lastReviewCreatedAt.withNano(reformatNano)); } if (LONG_TYPE_INCLUDE.contains(fieldName)) { final Path reviewPath = root.get(fieldName); @@ -149,7 +151,8 @@ private static Predicate checkLessThan(final String fieldName, final Review last if (LOCALDATETIME_TYPE_INCLUDE.contains(fieldName)) { final Path createdAtPath = root.get(fieldName); final LocalDateTime lastReviewCreatedAt = lastReview.getCreatedAt(); - return criteriaBuilder.lessThan(createdAtPath, lastReviewCreatedAt); + final int reformatNano = Math.round((float) lastReviewCreatedAt.getNano() / 1000) * 1000; + return criteriaBuilder.lessThan(createdAtPath, lastReviewCreatedAt.withNano(reformatNano)); } if (LONG_TYPE_INCLUDE.contains(fieldName)) { final Path reviewPath = root.get(fieldName); diff --git a/src/test/java/com/funeat/review/application/ReviewServiceTest.java b/src/test/java/com/funeat/review/application/ReviewServiceTest.java index ac67cd34..1b8e480a 100644 --- a/src/test/java/com/funeat/review/application/ReviewServiceTest.java +++ b/src/test/java/com/funeat/review/application/ReviewServiceTest.java @@ -386,9 +386,7 @@ class sortingReviews_성공_테스트 { final var productId = 단일_상품_저장(product); final var review1 = 리뷰_이미지test3_평점3점_재구매O_생성(member, product, 351L); - Thread.sleep(100); final var review2 = 리뷰_이미지test4_평점4점_재구매O_생성(member, product, 24L); - Thread.sleep(100); final var review3 = 리뷰_이미지test3_평점3점_재구매X_생성(member, product, 130L); 복수_리뷰_저장(review1, review2, review3);