Re: [Prevayler-discussion] Prevayler and thread-safety
Brought to you by:
jsampson,
klauswuestefeld
From: William P. <wi...@sc...> - 2009-01-25 11:08:41
|
Hi, Sergey. You are right that access like your examples is indeed unsynchronized. Klaus is right that if you want to do synchronized reads, you execute queries. This is the method to use: http://docs.rakeshv.org/java/prevayler/org/prevayler/Prevayler.html#execute(org.prevayler.Query) The simple way to think of it is that Prevayler provides transactional isolation by executing commands one at a time. So if you need a query that is isolated from all writes, package it up as a command object and feed it to the Prevayler object to execute. Does that help? William Sergey Didenko wrote: > Moving our discussion to the mail list... > > >> Hi, >> >> I'm considering using Prevayler for a web application. Could you answer a question about Prevayler and thread-safety? >> >> -------------------------------------------------------------- >> >> Prevayler guarantees that all the writes ( through its transactions) are synchronized. But what about reads? >> >> Is it right that dirty reads are possible if no explicit synchronizing is used (in user code)? >> >> Are they possible if a business object is read as: >> >> // get the 3rd account >> >> Accont account = (Bank)prevayler.prevalentSystem().getAccounts().get(2); >> >> ? >> >> If so what synchronizing strategies are good for a user code? >> >> (Consider a business object A contains a collection of business objects Bs), >> >> using a synchronized collection (of Bs inside of A), for example from java.util.concurrent package? >> >> synchronize collection reads outside transactions with the collection writes inside transactions, for example using "synchronized( collection )" code around reads and writes? >> >> -------------------------------------------------------------- >> >> Cheers, Sergey >> > > > Klaus: > >> Hi Sergey, >> > > >> Take a look at the javadoc for Prevayler.execute(Query) >> > > >> See you, Klaus. >> > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > To unsubscribe go to the end of this page: http://lists.sourceforge.net/lists/listinfo/prevayler-discussion > _______________________________________________ > "Databases in Memoriam" -- http://www.prevayler.org > |