https://stackoverflow.com/a/73478165/21138374 @EnableWebMvc showing date in array formateWe had two application on spring boot. One was spring rest api based & second was spring MVC based. We have megred both the application due to some business reasons as the context was the same ...stackoverflow.com@Configurationpublic class WebConfig implements WebMvcConfigurer { // 다른 코드 /** * HTTP..

Spring Framework
https://docs.spring.io/spring-framework/reference/core/validation/convert.html Spring Type Conversion :: Spring FrameworkWhen you require a sophisticated Converter implementation, consider using the GenericConverter interface. With a more flexible but less strongly typed signature than Converter, a GenericConverter supports converting between multiple source and target typesdocs.spring.io
개요 @IterableMapping(qualifiedByName = "toDto(RunHabit)") List toDtoList(List runHabits);@IterableMapping을 이용하면 리스트를 매핑할 때 요소 하나를 매핑할 메소드를 지정할 수 있다. 객체 하나를 매핑할 때 사용한 메소드를 재사용하여 같은 규칙을 사용할 수 있는 장점이 있다. 설명@Mapper(componentModel = "spring", uses = {HabitAlertMapper.class})@Named("RunHabitMapper")public interface RunHabitMapper { RunHabitMapper INSTANCE = Mappers.getMapper(RunHabitMapper.cla..
요약Spring Web은 HTTP Request Parameter(?property=vale)를 개발자가 정의한 클래스 객체로 바인딩하기 위해서 생성자, getter, setter 메소드를 호출한다배경Request Param 클래스를 만들다가 페이지네이션을 할 때 쓰는 속성 page와 size를 인터페이스화 해서 api에서 공통으로 관리하면 좋겠다는 생각을 했다./** * 목록 조회 API - 페이지네이션 기능을 사용할 때 쓰는 Request Param 속성. */public interface PaginationRequestParam { /** * 페이지 번호 */ Integer getPage(); /** * 페이지 당 데이터 수 */ Integer ge..
요약String -> Enum converter 인터페이스를 구현하고 추가한다enum class에는 String -> Enum 형태의 팩토리 메서드를 추가한다 (.of()) 출처https://www.baeldung.com/spring-enum-request-param Using Enums as Request Parameters in Spring | BaeldungLearn how to use enums as request parameters in Spring REST controllers and how to handle exceptions triggered by invalid input.www.baeldung.com
정리JPA의 메소드 deleteBy는 삭제되는 엔티티 개수만큼의 DELETE 문으로 실행횐다이는 성능 저하의 원인이 될 수 있다SELECT로 조건에 맞는 엔티티를 조회하고, id 조건으로 하나씩 삭제한다해결법@Query로 직접 JPQL 쿼리를 생성한다지금 프로젝트에서는 더 편하게 QueryDsl custom repository를 사용했다@Repository@RequiredArgsConstructorpublic class HabitAlertRepositoryCustomImpl implements HabitAlertRepositoryCustom { private final JPAQueryFactory queryFactory; @Override public void deleteByRunHabi..
상황UserDto.unlockingConstellation을 매핑할 때 UserConstellationMapper.toDto(UserConstellation)를 사용해서 매핑하려고 한다. 자동으로 생성된 코드에서는 UserDto.unlockingConstellation.constellation까지 .get()하여 의도하지 않은 SELECT가 발생하기 때문이다.public class UserDto {.../** * 현재 해금중인 유저 별자리 상태 */ private UserConstellationDto unlockingConstellation;}@Mapper(componentModel = "spring", uses={UserConstellationMapper.class})public i..
요약기본 설정: 닫히지 않은 트랜잭션이 있으면 해당 트랜잭션을 사용한다.propagation = Propagation.REQUIRED호출한 메소드에 `@Transactional` 걸려 있으면 그 메소드에서 쓰던 트랜잭션을 그대로 쓴다=> 하나의 transaction만 수행됨`@Transaction(propagation = )` 설정으로 바꿀 수 있다https://kghworks.tistory.com/106 [SPRING] @Transactional을 얼마나 이해했는지 보자목차 @Transcational CASE 정리 참고 2022.08.19 - [개발/데이터베이스 시스템] - 트랜잭션 (transaction) SQLException 발동! throw new SQLException(); } @Transca..