Hibernate query plan cache always miss with CriteriaBuilder

I’ve just found that SqmInterpretationsKey contains this logic:

public static SqmInterpretationsKey createInterpretationsKey(InterpretationsKeySource keySource) {
    if ( isCacheable ( keySource ) ) {
        final Object query = CRITERIA_HQL_STRING.equals( keySource.getQueryString() )
                ? keySource.getSqmStatement()
                : keySource.getQueryString();
        return new SqmInterpretationsKey(
                query,
                query.hashCode(),
                keySource.getResultType(),
                keySource.getQueryOptions().getLockOptions(),
                keySource.getQueryOptions().getTupleTransformer(),
                keySource.getQueryOptions().getResultListTransformer(),
                memoryEfficientDefensiveSetCopy( keySource.getLoadQueryInfluencers().getEnabledFetchProfileNames() )
        );
    }
    else {
        return null;
    }
}

It means that if I am using CRITERIA query then my query it’s not cached by the queryString but by SqmStatement object, which generates hashcode from default java Object class. It means that hashcode is always another and this query plans are treated as different query plans. Is it bug or feature?

This is by design - criteria queries do not have a query string, so the instance identity of the sqm representation is used as cache key.

For reference:

There is an open issue for implementing query plan caching for criteria based on their structure: [HHH-17002] - Hibernate JIRA