polygene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niclas Hedhman <nic...@hedhman.org>
Subject QuerySource
Date Thu, 14 Apr 2016 02:58:48 GMT
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

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

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