Hi,
I'm hoping someone has previously dealt with this or can point me in the right
direction.
I'm working on an application client using the glassfish ACC. I'm using an ACC
inected instance of EntityManager. My application will be used in a multi-user
environment.
When a user loads an entity to edit it, the EntityManager takes care of loading
it from the database, the entity becomes managed and I add it to the necessary
part of the UI and local data model. When a user closes the entity I remove it
from the UI / local data model, but it is still considered a managed entity by
the EntityManager.
The following is the scenario I'm trying to deal with:
Client 1 loads Entity A, modifies it, saves it, closes it. Client 2 loads
Entity A, modifies it, saves it, closes it. Client 1 reloads Entity A. At this
point the EntityManager for Client 1 provides the managed instance of the entity
that it has from the first load which doesn't contain the changes made by Client 2.
I know I can just call EntityManager.refresh(entity) before re-opening the
entity (in the UI) for editing, but it seems like a waste if no changes have
been made to the entity.
Is there a better way? Is there anything I should be aware of that would
improve the EntityManager's ability to refresh() entities (version fields or
something similar)?
Thanks in advance for any advice,
Ryan