You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@polygene.apache.org by Niclas Hedhman <ni...@hedhman.org> on 2016/04/14 04:58:48 UTC

QuerySource

Hi,
there is an interesting concept hidden deep inside the ModuleUnitOfWork,
called a QuerySource. There are two implementations, one which delegates to
an EntityFinder and a second one that use a java.lang.Iterable.

And then interestingly, the QueryBuilder has the following methods

public Query<T> newQuery( Iterable<T> iterable )
public Query<T> newQuery( QuerySource querySource )

The first wraps the Iterable in a IterableQuerySource, and the latter
method is called from ModuleUnitOfWork.newQuery() with the ModuleUnitOfWork
wrapped in a UoWQuerySource.

All in all, it feels icky and not clean at all. Since I think EntityFinder
a long time ago returned Entities and not EntityReferences, I suspect that
we should decouple the Query execution from the UnitOfWork, and it
effectively works as a regular service.

To support Query itself, i.e.
    extends Iterable<T>
    T find();

we should introduce a generic mechanism for EntityType Lookup via
visibility rules, in the UnitOfWork, via well specified interface.
Currently, there is a UnitOfWork.module() method, which documentation says
returns the module where the UnitOfWorkFactory.newUnitOfWork() was
executed, but looks like is the ModuleUnitOfWork, which is not the same.

The end goal is to break out Query from UnitOfWork, which is good for both
Query and UnitOfWork, especially as we might want to support custom
UnitOfWork.


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