【发布时间】:2022-01-02 18:14:51
【问题描述】:
我需要将属性Friends(这是一个ArrayList)从Mono<PersonEntity> 复制到Mono<UserEntity>(数据库中没有Friends 属性),但我没有找到正确的方法这样做,所以当我将 Mono<UserEntity> 映射到 Dto 时,字段 Friends 结果是一个空数组 []。
public Mono<Dto> findEntityByIdAndLabel(Long id, String label) {
return getPersonByIdAndLabel(id, label).flatMap(person -> {
return UserRepository.findByID(id);
})
.switchIfEmpty(Mono.error(new EntityNotFoundException(entity.toString(), id.toString(), label)))
.map(this::mapper);
}
我想我应该在findById(id) 之后添加一些东西,但我尝试过的一切都没有奏效。
感谢您的宝贵时间
【问题讨论】:
标签: java spring mapping spring-webflux