Mapstruct를 쓰며 entity -> long, long -> entity 매핑이 필요했다.
@Mapper
public interface AMapper {
@Mapping(source = "bs", target = "bIds", qualifiedByName = "entityToId")
public ADto aToADto(A a);
@Named("entityToId")
public static Long entityToId(Entity entity) {
return entity.getId();
}
@Named("idToEntity")
public static Entity idToEntity(Long id){
return Entity.builder().id(id).build();
}
}
커스텀으로 매핑 관계를 지정해주고 qualifiedByName에 적용하면 끝이다.
'Backend' 카테고리의 다른 글
[SpringBoot] - JPA Mysql sql_mode=only_full_group_by 에러 (0) | 2023.12.12 |
---|---|
[SpringBoot] - Redis LocalDateTime 역직렬화 에러 (0) | 2023.12.12 |
[SpringBoot] - CacheEvict key 패턴과 매치되는 경우 제거하기 (0) | 2023.12.12 |
Mac - mysql access denied for user 'root'@'localhost' (using password: yes) (0) | 2023.12.12 |
[Kafka] kafka 설치부터 세팅까지 (0) | 2023.12.12 |