Subquery returning a Set or a List not working as intended

I have a problem with a query using the CriteriaBuilder in spring-data-jpa 2.6.2 with Hibernate 5.6.5.

I have 2 entities :

public class Person {
    private String id;

public class TemporaryDataSetAttr {
    private String id;

    private String correlationId;

    @CollectionTable(indexes = @Index(name = "IDX_TMP_DATA_ID_SET_VALUES", columnList = "temporary_data_set_attr_id"))
    private Set<String> strValues = new HashSet<>();

And here is my query :

(root, query, cb) -> {
    Subquery<Set<String>> subquery = query.subquery(TemporaryDataSetAttr_.strValues.getJavaType());
    Root<TemporaryDataSetAttr> subRoot = subquery.from(TemporaryDataSetAttr.class);
        .where(cb.equal(subRoot.get(TemporaryDataSetAttr_.correlationId), correlationId));

    return cb.not(root.get(;

The produced SQL query is :

select as id1_0_, as name2_0_ 
from person person0_ 
where not in (
        select . 
        from temporary_data_list_attr temporaryd1_ 
        cross join temporary_data_list_attr_str_values strvalues2_
        where and temporaryd1_.correlation_id=?

The select clause in the subquery is missing the column name, only the dot separating the table name from the column name is present.
Using EntityManager#createNativeQuery and adding the table and column names to the generated query through the CriteriaBuilder, i have the expected result.
I tried with an ListAttribute instead of the SetAttribute but it is the same result.

This looks like an Hibernate bug.

I pushed a reproducer project on my github :

Thanks for the reproducer, but I think the “bug” is that you don’t get a good exception. In JPQL it is illegal to use a plural attribute path anywhere but in the FROM clause or a collection predicate, so some kind of error is expected. What you want to do requires that you join the plural attribute and select the join.

I could not find how to write the request using joins so i used a SingularAttribute instead.

Thank you for your answer.