I see that for the other query types there is a specialized Key object defined. Only for Native there is none. NativeSQLQuerySpecification is used for this.
You are essentially arguing that NativeSQLQuerySpecification is not a good key because it doesn't have "Key" in its name... It's really as simple as (variances in 4.x to 5.x aside) NativeSQLQuerySpecification defines the things it needs to uniquely identify a native query plan. Overall, I'm not really understanding where this leak comes from. Are you closing the SessionFactory? SessionFactory#close releases the QueryPlanCache which in turn releases its reference to these things |