Skip to content

Commit

Permalink
🔗 :: (#445) fetch join으로 인한 in query 문제
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsoftj1123 authored Nov 12, 2023
2 parents 191ace5 + d24e2b9 commit 4eaa116
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public static class TeacherRecruitmentResponse {
private LocalDate start;
private LocalDate end;
private Boolean militarySupport;
private Long companyId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@ public class RecruitmentVO {
private final Long requestedApplicationCount;
private final Long approvedApplicationCount;
private final Long isBookmarked;
private final Long companyId;

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public TeacherQueryRecruitmentsResponse execute(String companyName, LocalDate st
.applicationApprovedCount(recruitment.getApprovedApplicationCount())
.recruitmentCount(recruitment.getTotalHiring())
.recruitmentJob(getJobKeywords(recruitment.getJobCodes()))
.companyId(recruitment.getCompanyId())
.build()
).toList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public void deleteApplicationByIds(List<Long> applicationIds) {

@Override
public List<Application> queryApplicationsByIds(List<Long> applicationIds) {
return applicationJpaRepository.findAllByIdIn(applicationIds).stream()
return applicationJpaRepository.findByIdIn(applicationIds).stream()
.map(applicationMapper::toDomain)
.toList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

public interface ApplicationJpaRepository extends JpaRepository<ApplicationEntity, Long> {

@Query("select a from ApplicationEntity a join fetch a.attachments where a.id in(?1)")
List<ApplicationEntity> findAllByIdIn(List<Long> applicationIds);
List<ApplicationEntity> findByIdIn(List<Long> applicationIds);

void deleteByIdIn(List<Long> applicationIds);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import team.retum.jobis.domain.application.model.ApplicationStatus;
import team.retum.jobis.global.annotation.ValidListElements;

import javax.validation.constraints.NotNull;
import java.util.List;
Expand All @@ -12,8 +11,8 @@
@NoArgsConstructor
public class ChangeApplicationsStatusWebRequest {

@ValidListElements
private List<Long> applicationIds;
@NotNull
private List<@NotNull Long> applicationIds;

@NotNull
private ApplicationStatus status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ public List<RecruitmentVO> queryRecruitmentsByFilter(RecruitmentFilter filter) {
recruitAreaEntity.hiredCount.sum(),
requestedApplication.countDistinct(),
approvedApplication.countDistinct(),
bookmarkEntity.count()
bookmarkEntity.count(),
companyEntity.id
)
)
.from(recruitmentEntity)
Expand Down Expand Up @@ -137,6 +138,7 @@ public Long getRecruitmentCountByFilter(RecruitmentFilter filter) {
.select(recruitmentEntity.count())
.from(recruitmentEntity)
.join(recruitmentEntity.company, companyEntity)
.join(recruitmentEntity.recruitAreas, recruitAreaEntity)
.where(
eqYear(filter.getYear()),
betweenRecruitDate(filter.getStartDate(), filter.getEndDate()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public QueryRecruitmentsVO(Long recruitmentId, RecruitStatus recruitStatus, Loca
LocalDate endDate, String companyName, CompanyType companyType,
Integer trainPay, boolean militarySupport, String companyLogoUrl,
String jobCodes, Integer totalHiring, Long requestedApplicationCount,
Long approvedApplicationCount, Long isBookmarked) {
Long approvedApplicationCount, Long isBookmarked, Long companyId) {
super(recruitmentId, recruitStatus, startDate, endDate, companyName,
companyType, trainPay, militarySupport, companyLogoUrl, jobCodes,
totalHiring, requestedApplicationCount, approvedApplicationCount, isBookmarked);
totalHiring, requestedApplicationCount, approvedApplicationCount, isBookmarked, companyId);
}
}

0 comments on commit 4eaa116

Please sign in to comment.