On 06/15/2011 07:28 PM, Dick Wall wrote:
This does take a little getting used to, the "new" way often involves
making a database update through a DSL expression (like a SQL update
statement, which leaves the original object intact and just changes
the data in the database), and then re-querying the object to get it
in its new state, rather than just updating fields and saving the new
object. It's a trade-off I willingly make though for the extra safety
and consistency of handling only immutable instances in my programs.
It ends up being a bit like a database enforced STM. Another advantage
is you can easily disconnect these objects from the database and hold
them as simple in-memory representations, getting a ton of performance
improvement by dropping all of the semaphors for updates, dirty
caches, etc. If you need the most recent version of the object,
requery it and get on with life.

I'm curious about this, not really for Scala (Dick, please forgive me :-) but because I'm aware of the value of immutability and I'm slowly emancipating (or try to emancipate, in some areas) from getters and setters in Java. Persistence is one of my biggest question marks, I imagine that the solution is as you described it, but I'm still unable to imagine some working code (in Java). While I understand the performance improvements because of no more locks, I'm guessing whether you have a performance hit because of re-querying, how tolerable is it, whether it is tolerable always or only in certain scenarios, etc... And as we're here, does somebody have a pointer to an "immutable persistence" solution made in Java?

--
Fabrizio Giudici - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
java.net/blog/fabriziogiudici - www.tidalwave.it/people
fabrizio.giud...@tidalwave.it

--
You received this message because you are subscribed to the Google Groups "The Java 
Posse" group.
To post to this group, send email to javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to