[concurrency-interest] Hibernate domain objects
ashpublic at mac.com
Thu Jun 25 07:02:19 EDT 2009
Many thanks for the help so far on resetting my way of thinking when
it comes to concurrency.
I would like to apply those lessons on my hibernate codebase, which
for the uninitiated, consists
of a bunch of java beans style pojos with getters and setters. These
are automatically called from the
hibernate api in order to sync with the database rows. As I see it
there are a number of options:
1. This is a case where the domain model is genuinely mutable.
Following the path of least
resistance means that I shouldn't try to bend this domain layer into
something it wasn't supposed
to be and therefore introduce a little concurrency api in order to
make it threadsafe.
2. Manage the lifecycle of the domain objects to ensure they are only
ever used locally to a
thread. This means that care would have to taken when for example
using the long conversation
pattern, where the session and its domain objects need to outlive the
In other words don't make the domain objects threadsafe but work hard
in the rest of the
application that there is never any contention over them.
3. Consider the domain objects as nothing more than parameter holders
and wrap them
inside genuine rich, immutable domain objects.
I'm sure there are more options and that there is no simple answer,
but I would welcome any
- Ashley Williams
More information about the Concurrency-interest