tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Kildén <>
Subject Re: OpenJPA and DTO problem
Date Fri, 16 May 2014 15:34:29 GMT
Hi Romain,

Well in the else block the DTO and the Entity will both be new so the
version will never be set.


Thanks, I am aware of this basic rule but I got confused by reading several
times that if you use DTO remember to care for the version field. However I
guess this means I am supposed to throw ApplicationException rollback=true
myself when I discover that the DTO is old... This actually makes sense
because the logic required for optimistic lock management is custom and
it's also more efficient for me to throw while I convert back to entity.

By the way when I am testing optimistic locking
@Test(expected=MyApplicationException) works poorly, seems that at least
for tests it gets wrapped with EJBException. I am pretty sure I managed to
make it ApplicationException correctly because otherwise the exception /
logging hints that ApplicationException could be used instead to avoid the


On 14 May 2014 20:19, agumbrecht <> wrote:

> You should let the JPA provider manage the @Version field, don't try and
> change it or read it yourself or you'll always get this error. It's
> controlled internally by the provider and is to do with optimistic locking.
> If you want to manage your own entity version the, i.e. versioned data row,
> then use a different name/field and treat it like any other field - Don't
> flag it with @Version.
> Hope this helps.
> Andy.
> -----
>     --
>     Andy Gumbrecht
>     TomEE treibt Tomitribe ! |
> --
> View this message in context:
> Sent from the OpenEJB User mailing list archive at

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