【发布时间】:2018-05-13 16:59:40
【问题描述】:
我有一个 Pojo:
class Pojo{
String name;
String surname;
}
还有一个 jpa/hibernate 实体:
class Entity{
Long id;
String code;
List<EntityPojo> ep;
}
最后是实体pojo
class EntityPojo{
Long id;
String name;
String surname;
}
在我的代码中:
//I receive a pojo from the rest call and I want to update
Entity entity = repo.findByCode("aCode");
//at this point my entity pojo IDs are correctly filled!
dozerMapper.map(pojo, entity);
//after the map the IDs are null!!
repo.save(entity); //BAM!
如您所见,映射只是删除了 ID,这让我想到了休眠中的约束异常……这是为什么呢?
【问题讨论】:
标签: java spring-data-jpa dozer