After upgrade to Hibernate 6 slower performance when executing query the first time due to ANTLR?

Sorry for not responding earlier. I have been tasked with other stuff.

I did manage to build the query with just JPQL and the performance is nearly the same as with QueryDSL.

But, I downgraded hibernate-core to 6.2.33.Final and the query execution time did improve significantly. With version 6.6.5 the query took around 2.8 seconds to execute, whereas with version 6.2.33.Final it only took around 0.5 seconds (roughly measured with a unit test).
(Out of interest I also tried with version 6.3.2.Final and where it took around 0.7 seconds.)

Interestingly, the flame graphs for the different versions look similar it just seems to take longer.

I suppose it has something to do with the predicates as the query uses many. When I have time again I will try to create an example with the test case template.

Btw org.hibernate.cfg.QuerySettings.QUERY_PLAN_CACHE_ENABLED mentions that it is disabled by default. However, in org.hibernate.query.internal.QueryEngineImpl.buildInterpretationCache it is enabled by default - see hibernate-orm/hibernate-core/src/main/java/org/hibernate/query/internal/QueryEngineImpl.java at 057e574df267260d0ebffaa08f396c8725ca21ab · hibernate/hibernate-orm · GitHub

I tried to explicitly disable it but I couldn’t figure out how to do it in a Spring Boot Data JPA project. Do you know how to do that?