Useless class lookup during constant conversion

Description

Hibernate performs useless class lookup when applying the constant conversion. For instance, in the query SELECT p FROM Event p WHERE p.eventstart<?1, there will be a class lookup for ch.astorm.entities.Event and for p.eventstart and this will occur each time the query needs to be compiled by Hibernate.
There will be a warning in the logs just as mentioned in the issue HHH-11245.

The "randomess" described in is caused by query plan caching (see HHH-4627). Hence, to reproduce the warning systematically, a "new" query needs to be given to Hibernate, which is somewhat easy if they are not parametrized.
So, I set the property hibernate.query.plan_cache_max_size to 40 (which will be the minimum accepted value because of the BoundedConcurrentHashMap fixed parameters created in QueryPlanCache) and created a simple loop in each query to force renewal of the cache:

My patch suggests transforming the method handleDotStructure in QueryTranslatorImpl (line 613) to:

This check will avoid entity lookups (because the expression ch.astorm.entities.Event will cause a lookup on ch.astorm.entities which will be always null), but the patterns like p.eventstart will still cause IMHO a useless lookup which could probably be avoided by using the parsed HQL query.

Any suggestion is welcome.
Thanks in advance.

Environment

OpenJDK 8, Glassfish 4.1.1

Status

Assignee

Unassigned

Reporter

Cédric Tabin

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Trivial
Configure