File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Synchronization of objects state Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Synchronization of objects state" Watch "Synchronization of objects state" New topic

Synchronization of objects state

A Teja

Joined: Mar 18, 2004
Posts: 6
In our project we propose to have wrappers (adapters) to the session facade layer so that we expose a POJO API to the external app. users.
My question is related to synchronization of the POJO objects that the API users will use, and the remote objects exposed through the session facade. For instance if an API user were to call some setters on a POJO object (like User object), which just sets these properties locally, and then finally call oUser.Update(). If the Update were to fail the object state in the DB and the local copy would be out of synch.
There are some possibilities that we have explored:
1. Save the state of the local object before calling setters and if the remote call fals restore the state.
2. Have the Update take a DTO which is used to transfer the state to the session layer. If that succeedes then reflect that state in the loacl object too.
3. After each Update reload the state from the session facade, failing which restore the saved state somehow. (we will still need to store state)
The problem I assme is not related to EJB. Even if we were going through JDBC such a problem would exist. What is the standard best practice to take care of such a scenario??
A Teja

Joined: Mar 18, 2004
Posts: 6
I haven't seen a single reply to this question. Could someone pl. shed some light on this issue. Would really appreciate it.
I agree. Here's the link:
subject: Synchronization of objects state
It's not a secret anymore!