2

There is a similar question here for Hibernate with an answer by Palladium explaining how to merge a detached object back to the entity cache without increasing the version. Is the same also achievable with eclispelink? How?

I am aware how to achieve to goal with native queries, but that has drawbacks.

Alex K.
  • 220
  • 3
  • 10
  • I'm curious on the reasoning it is required. Caching generally means that the changes will not be picked up without forcing refreshes everywhere, as EclipseLink won't know that anything changed within the object. EclipseLink's non-jpa methods and queries might be able to help, specifically the WriteObjectQuery and UpdateObjectQuery classes. – Chris Oct 02 '20 at 15:52
  • The reason is that generally our app uses optimistic locking. But for this special case we need to update some fields asynchronously. It is like a background process that runs periodically and does some updates. I do not want the user to get optimistic locking exceptions because of this. Rather the in case of concurrency with a user update the asynch. background edit should be overwritten. I currently solved it with native queries and afterwards clearing the respective objects from JPA cache. But a solution like in hibernate (see link) would be better. – Alex K. Oct 03 '20 at 14:50

0 Answers0