| Hi Everyone, I've attached a patch on the 4.2 branch that demonstrates the issue. When we use UserTypes with our query, the QueryPlanCache grows with every invocation. By implementing hashCode/Equals on CustomType the cache works as expected because these are then used by the hashCode/Equals of NativeSQLQuerySpecification I have no deep understading of Hibernate internals so this may not be the best fix. Maybe these CustomTypes should be managed internally as singletons like we see for BooleanType, IntegerType etc : we only ever see one instance of these classes referenced in the NativeSQLQuerySpecification.queryReturns. If you can review and verify our understanding/solution we can then create a PR for 5.2 and in the meantime roll our own 4.2 version. Hope this clarifies, thanks in advance |