fix(doctrine): reduce code duplication

Move the shared logic of the CacheWhereBuilder
to AbstractCacheWhereBuilder