tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Kildén <karl.kil...@gmail.com>
Subject OpenJPA and DTO problem
Date Wed, 14 May 2014 17:53:41 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message