tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: OpenJPA and DTO problem
Date Wed, 14 May 2014 18:03:31 GMT
Hi

does it happen if you don't do it for the else case (new Fact())? But
I guess it is linked to a relationship maybe


Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau


2014-05-14 19:53 GMT+02:00 Karl Kildén <karl.kilden@gmail.com>:
> 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
View raw message