public Table<?> addJoins(
            Table<?> fromPart,
            final Field<Long> metaIdField,
            final Set<Integer> usedValKeys) {

        for (Integer id : usedValKeys) {
            final MetaVal metaVal = getAliasedMetaValTable(id);

            fromPart = fromPart.leftOuterJoin(metaVal)
                    .on(metaIdField.eq(createMetaIdField(id))); //Join on meta_val
        }
        return fromPart;
    }
If the criteria contains many terms that come from meta_val then we need to join to meta_val
multiple times, each time with a new table alias.

@param usedValKeys The list of meta_key IDs that feature in the criteria. One join will be
                   added for each.
@return The query with joins added
stroom-meta/stroom-meta-impl-db/src/main/java/stroom/meta/impl/db/MetaExpressionMapper.java