Affects Version/s: 5.2.4
Fix Version/s: None
Environment:OpenJDK 8, Glassfish 4.1.1
Last commented by a user?:true
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 Closed .
The "randomess" described in
is caused by query plan caching (see
). 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.