I have a Pojo:
class Pojo{
String name;
String surname;
}
and a jpa/hibernate entity:
class Entity{
Long id;
String code;
List<EntityPojo> ep;
}
finally the entity pojo
class EntityPojo{
Long id;
String name;
String surname;
}
In my code I do:
//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!
As you can see the mapping just deletes the IDs and this brings me to the constraint exception in hibernate...why is that?