Hi,
I use openjpa with DTO and when I try to manage @Version I get an
exception: Detected attempt to modify field
"com.kildeen.ref.domain.BaseEntity.version" with value strategy "restrict".
What I do is, I use find if the DTO has id. I then copy back the version
field but it seems It does not work since I get that exception... Can it be
done somehow?
Code below:
@Override
protected Fact toEntity(final FactDTO dto) {
Fact fact;
if (dto.getId() != 0) {
fact = em.find(Fact.class, dto.getId());
} else {
fact = new Fact();
}
if (dto.getVersion() != entity.getVersion()) {
entity.setVersion(dto.getVersion());
}
cheers