Identify map

S

Steven Wolf

Hi folks,

i use the identity map pattern [Fowler PoEAA] in my project, to
store/cache many domain objects there. But what happen if the
persistence data (sql) change? The user will still use some domain
objects, which are no more up-to-date. I can solve that, if i use a
server-side identity map, to provide a map for all users/apps and
update a domain object in the map when a UPDATE/INSERT/DELETE get
fired on the persitence data.

But do you have some ideas how to solve that on a client-side identity
map?

Steven.
 
R

R.F. Pels

Steven said:
i use the identity map pattern [Fowler PoEAA] in my project, to
store/cache many domain objects there. But what happen if the
persistence data (sql) change? The user will still use some domain
objects, which are no more up-to-date. I can solve that, if i use a
server-side identity map, to provide a map for all users/apps and
update a domain object in the map when a UPDATE/INSERT/DELETE get
fired on the persitence data.

But do you have some ideas how to solve that on a client-side identity
map?

Hmmm. That depends. If you access the database in such a way that the user
always has a consistent view of the data, you do not need to update the
objects, but you must resolve conflicts if the user updates/inserts/deletes
an object and its underlying representation.

Even if you notify users of changes in the underlying data, it is still
possible that they encounter a conflict if they perform a change due to a
race condition, so, conflict resolution is needed anyway.

Basically, what you do is fit the objects representing the data with methods
that check if the underlying data is still the same or still (non)existent
at the moment the user wants to propagate the changes in the object to the
database, and ask the user what to do if a conflict is raised. Or you can
adopt a scheme where 'last updater wins', for example.
 
S

Steven Wolf

Basically, what you do is fit the objects representing the data with methods
that check if the underlying data is still the same or still (non)existent
at the moment the user wants to propagate the changes in the object to the
database, and ask the user what to do if a conflict is raised.

that sounds really good, something like
OnDirty()
{
mapper.findById ( this.id )
}

i thought also about, to realease cached objects after 5 minutes, so a
user retrieve updated data max. after 5 minutes.

but anyway, thats a real good simple solution..thanks!
 
R

R.F. Pels

Steven said:
i thought also about, to realease cached objects after 5 minutes, so a
user retrieve updated data max. after 5 minutes.

but anyway, thats a real good simple solution..thanks!

You really should look into things like hibernate for example. A lot of
stuff is already done for you in that library. Quite powerfull.
 
S

Steven Wolf

R.F. Pels said:
You really should look into things like hibernate for example. A lot of
stuff is already done for you in that library. Quite powerfull.

thanks, i'll look into.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top