[concurrency-interest] Hibernate domain objects

Hanson Char hanson.char at gmail.com
Thu Jun 25 11:42:09 EDT 2009


Or detach/clone every persistence objects of Hibernate into genuine POJO
instances via reusing the same classes, and then confine the use of these
POJO's in the executing threads.  No concurrency issue, nor problems of long
conversation pattern since these pojo's are independent of Hibernate
sessions.

(Shameless plug: I use Beanlib to make the cloning trivially easy.)

Cheers,
Hanson

On Thu, Jun 25, 2009 at 4:02 AM, Ashley Williams <ashpublic at mac.com> wrote:

> 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
> current thread/transaction.
> 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
> insight.
>
> Thanks
> - Ashley Williams
> _______________________________________________
> Concurrency-interest mailing list
> Concurrency-interest at cs.oswego.edu
> http://cs.oswego.edu/mailman/listinfo/concurrency-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cs.oswego.edu/pipermail/concurrency-interest/attachments/20090625/ed35ecb3/attachment.html>


More information about the Concurrency-interest mailing list