On Mon, Oct 19, 2009 at 10:35 AM, Rickard Öberg <[email protected]> wrote:
> On 2009-10-16 19.59, Kent Sølvsten wrote:

>> On a sidenote: What is the proper way to handle partially loaded
>> entities when exiting a UnitOfWork? Should state not yet loaded be
>> lazy-loaded on exit, or should the client be prepared for
>> LazyLoadExceptions? If state is lazy loaded on exit, it will probably be
>> an incentive to use value objects.
>
> Why would you want to do anything on exiting a UoW other than just drop the
> state? Or are you assuming there's caching going on?

This is a common ORM issue, a.k.a detached state. In ORM, the
'session' is approximately our UoW but it holds a connection to the
DB, so it should be short-lived. So, what people do is "detach" the
object from the session, and once it has been manipulated it is
"attached" back to a new (later) session and persisted. With such
strategy the "hollowness" of objects become an issue.

This is less relevant in Qi4j, as one can hold on to the UnitOfWork
much longer. One thing, however, that I might be fond of seeing is
"toValue()" of entities, in which case the entire graph is pulled out
and made into a ValueComposite. I understand that this is semantically
challenging, but I think would be a great tool, especially for "thick,
domain-less" clients. I don't think that the opposite should exist, at
least not for an existing entity (perhaps into a builder).


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to