Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] OptimisticLockException on query, but with one user, no changes

A few things.

By default in JPA any query execution triggers a flush(), unless you set the
flushMode of the EntityManager or Query.  This is required by the JPA spec,
and done to ensure the query is querying the current state of the
persistence context.  I would normally recommend setting the flushMode to
COMMIT.

Now if this is your first query, the persistence context should be empty, so
flush should do nothing.  Is this really the first thing you do?  Or have
you executed other queries, or persist or merged objects?

Now, why your PreUpdate event is being fired is odd if you have not changed
any of these objects.  Ensure that you are not changing the objects.  Ensure
you do not have a PostLoad event that changes something.  Are you using
property access, do any of your get/set methods have side-effects that
change something?  Try using field access.

Also include the code and the exception stack trace.




--
View this message in context: http://eclipse.1072660.n5.nabble.com/OptimisticLockException-on-query-but-with-one-user-no-changes-tp153961p154071.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.


Back to the top