JAVA16 복합키 Entity Update 복합키로 생성된 엔티티를 수정할 때 //아래는 뽑아온 리스트 안에 업데이트 할 객체만 수정해주기 noticeReadHistoryList.stream() .filter(//바깥 foreach와 동일한지 체크) .forEach(noticeReadHistory -> { noticeReadHistory.setRegisterDt(LocalDateTime.parse(item.getRegisterYmdt(), formatter)); noticeReadHistory.setModifyDt(StringUtils.isNotBlank(item.getModifyYmdt()) ? LocalDateTime.parse(item.getModifyYmdt(), formatter) : null); }); //아래는 (업데이트를 위한) 새.. 2023. 9. 17. Sql In, Not In 절 (JDBC JPA) QueryDsl 활용 where 문의 or 대신 in을 활용하려 한다.이유는 or는 인덱스 활용 불가능이고 in은 인덱스를 활용할 수 있어 in 절이 속도 면에서 우위가 있다. - sql in 절의 특징sql in ( “1”,”2”) 의 경우는 내부 콤마가 or가 되고.sql Not In (“1”, “2”)의 경우는 내부 콤마가 and가 된다. - Query dsl 특징where(000, 000) 의 경우는 내부 콤마가 and가 된다 - 실제 동적쿼리 적용 코드 @Override public List findByReceiverIdAndStatusOrStatus(String receiverId, AcceptStatus... acceptStatuses) { List kdKDGifts = queryFacto.. 2023. 1. 17. java Stream 문법 cancelOrderDtos.setCancelProductInMemberNo(updateOrderRequestDtos .stream() .collect(Collectors.groupingBy(UpdateOrderRequestDto::getMemberNo, Collectors.mapping(UpdateOrderRequestDto::getMallProductNo, Collectors.toList()) ))); memberNo로 상품 여러개를 List로 담는다.. result = Map 2023. 1. 13. QueryDsl 동적쿼리 사용 (SpringBoot, JPA) Tag 테이블에는 team_id가 외래키로 존재한다. 즉, 하나의 Team은 다수의 Tag를 가질 수 있다. -RequestBody (Rest API) -RequestTags @Data public class RequestTags { private List tags; } -TeamController /** * 태그로 전체 게시판 검색 */ @ApiOperation(value = "태그로 전체 게시판 조회 URL") @PostMapping("/api/tags") public ResponseTagsInTeam tagsInTeam( @RequestBody RequestTags requestTags, @PageableDefault(size = 10, sort = "createdDate", direction = .. 2022. 11. 25. 이전 1 2 3 4 다음