docs: @SuppressWarnings("unchecked")
    protected List<EntityImpl> getList(String dbQueryName, Object parameter, 
        CachedEntityMatcher<EntityImpl> cachedEntityMatcher, boolean checkCache) {
  
      Collection<EntityImpl> result = getDbSqlSession().selectList(dbQueryName, parameter);
      
      if (checkCache) {
        
        Collection<CachedEntity> cachedObjects = getEntityCache().findInCacheAsCachedObjects(getManagedEntityClass());
        
        if ( (cachedObjects != null && cachedObjects.size() > 0) || getManagedEntitySubClasses() != null) {
          
          HashMap<String, EntityImpl> entityMap = new HashMap<String, EntityImpl>(result.size());
          
          // Database entities
          for (EntityImpl entity : result) {
            entityMap.put(entity.getId(), entity);
          }
  
          // Cache entities
          if (cachedObjects != null && cachedEntityMatcher != null) {
            for (CachedEntity cachedObject : cachedObjects) {
              EntityImpl cachedEntity = (EntityImpl) cachedObject.getEntity();
              if (cachedEntityMatcher.isRetained(result, cachedObjects, cachedEntity, parameter)) {
                entityMap.put(cachedEntity.getId(), cachedEntity); // will overwite db version with newer version
              }
            }
          }
          
          if (getManagedEntitySubClasses() != null && cachedEntityMatcher != null) {
            for (Class<? extends EntityImpl> entitySubClass : getManagedEntitySubClasses()) {
              Collection<CachedEntity> subclassCachedObjects = getEntityCache().findInCacheAsCachedObjects(entitySubClass);
              if (subclassCachedObjects != null) {
                for (CachedEntity subclassCachedObject : subclassCachedObjects) {
                  EntityImpl cachedSubclassEntity = (EntityImpl) subclassCachedObject.getEntity();
                  if (cachedEntityMatcher.isRetained(result, cachedObjects, cachedSubclassEntity, parameter)) {
                    entityMap.put(cachedSubclassEntity.getId(), cachedSubclassEntity); // will overwite db version with newer version
                  }
                }
              }
            }
          }
          
          result = entityMap.values();
          
        }
        
      }
      
      // Remove entries which are already deleted
      if (result.size() > 0) {
        Iterator<EntityImpl> resultIterator = result.iterator();
        while (resultIterator.hasNext()) {
          if (getDbSqlSession().isEntityToBeDeleted(resultIterator.next())) {
            resultIterator.remove();
          }
        }
      }
  
      return new ArrayList<EntityImpl>(result);
    }