polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject Re: UnitOfWork Exception handling?Usecase ?
Date Mon, 18 Apr 2016 08:47:23 GMT
Sorry, I don't think I understand your question....

The UnitOfWork is running an isolation of the stuff you are doing, against
the underlying store. That means that any action within the UoW will not be
visible to the outside until the uow.complete() has been successfully
completed.
This isolation also means that updates of any entities in UoW1 that is used
in UoW2 will (if UoW completes first) cause UoW2 to fail
(ConcurrentModificationException).

Usecase is an "attachment" one can assign to a UnitOfWork. This can be
picked up by any participant in the UoW. The simple case is just a name,
but can be any meta data you want.

Cheers
Niclas


On Mon, Apr 18, 2016 at 2:51 PM, zhuangmz08 <zhuangmz08@qq.com> wrote:

> Hi,
> I'm confused on exception handling inside unitofwork.
> 1. The following [Exception e] will never reached? because when I found
> duplicated entity, the exception will not triggered until uow.complete().
> However, after uow.complete(), it will throw an exception for outter scope
> handler. Is this understanding correct?
> How to handling this kind of exception.
> 2. What does Usecase mean here. When I have Usecases in the same name more
> than one time, it doesn't throw any exception?
>
>
> public void test() throws Exception {
> UnitOfWork uow = module.newUnitOfWork(newUsecase("blabla"));
> try {
>    entity = uow.newEntity(...);
> } catch (Exception e) {
>    // never reached????
> }
> uow.complete();
> }
>
>
> Thanks a lot.




-- 
Niclas Hedhman, Software Developer
http://zest.apache.org - New Energy for Java

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message