class ParameterEntryDAO {

    public List<ParameterEntry> list(QueryRunner queryRunner, JdbcParameter parameter, ParameterEntriesFilter filters) {
        SelectQuery query = QueryFactory.selectAll().from(configuration.parameterEntryEntityName())
                .where("fk_parameter = :parameterId")
                .withArgument("parameterId", parameter.getId());

        int maxDistinctLevels = configuration.levelColumnCount();
        int levelIndex = 0;
        for (Level level : parameter.getLevels()) {
            if (levelIndex >= maxDistinctLevels) {
                break;
            }

            if (filters.hasFilter(level.getName())) {
                LevelFilter filter = filters.levelFilter(level.getName());

                query.append(" and (upper(" + level(levelIndex) + ")").append(levelSearchCondition(filter, levelIndex)).append(")");
                query.withArgument(level(levelIndex), FilterConverter.parseAntMatcher(filter.value()));
            }

            levelIndex++;
        }

        Map<String, Integer> levelIndexMap = createLevelIndex(parameter);
        for (LevelSorting levelSorting : filters.sorting()) {
            if (levelIndexMap.containsKey(levelSorting.level())) {
                levelIndex = levelIndexMap.get(levelSorting.level());
                if(levelIndex < maxDistinctLevels) {
                    query.orderBy(level(levelIndex), parseSortOrder(levelSorting.direction()));
                }
            }
        }

        if (filters.applyPaging()) {
            query.limit(filters.pageSize(), filters.offset());
        } else if (filters.applyLimits()) {
            query.limit(filters.pageSize());
        }

        return queryRunner.queryList(query, new ParameterEntryMapper(configuration));
    }

    public  ParameterEntryDAO(DefaultJdbcConfig configuration);

}