How does unit of work supposed to work?
If I have the following qi4j application structure:
[Web] --- [Domain] -- [Persistence]
[ ] = layer
-- = uses
Web has open unit of work in view.
Domain has entities with layer visibility and domain services.
If Web layer invoke a domain service and that service returns a query.
And the sequence of unit of work
Open session in view
- new unit of work
web controller
- invoke business service
business service
- new unit of work
- create query
- complete unit of work
- return query
- iterate query
This exception is thrown:
org.qi4j.entity.UnitOfWorkException: Unit of work has been closed
org.qi4j.runtime.entity.UnitOfWorkInstance.checkOpen(UnitOfWorkInstance.java:620)
org.qi4j.runtime.entity.UnitOfWorkInstance.module(UnitOfWorkInstance.java:519)
org.qi4j.runtime.query.EntityQuery.loadEntity(EntityQuery.java:156)
org.qi4j.runtime.query.EntityQuery.access$000(EntityQuery.java:37)
org.qi4j.runtime.query.EntityQuery$1.next(EntityQuery.java:111)
org.qi4j.samples.dddsample.spring.ui.CargoTrackingViewAdapter.<init>(CargoTrackingViewAdapter.java:35)
org.qi4j.samples.dddsample.spring.ui.CargoTrackingController.onSubmit(CargoTrackingController.java:56)
So.. how does this supposed to work?
Should business service not close the unit of work and complete it
twice on the UI? (This feels very wrong).
Should there be a mechanism to reattach query to web unit of work?
If we do that, the query no longer be able to see all those entities.
As they're private to domain layer.
Regards,
Edward Yakop
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev