diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryKey.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryKey.java index 036a43b937..86f10ecb61 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryKey.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryKey.java @@ -105,15 +105,12 @@ public class QueryKey implements Serializable { private int generateHashCode() { int result = 13; result = 37 * result + sqlQueryString.hashCode(); - result = 37 * result + ( firstRow==null ? 0 : firstRow ); - result = 37 * result + ( maxRows==null ? 0 : maxRows ); + // Don't include the firstRow and maxRows in the hash as these values are rarely useful for query caching +// result = 37 * result + ( firstRow==null ? 0 : firstRow ); +// result = 37 * result + ( maxRows==null ? 0 : maxRows ); result = 37 * result + ( tenantIdentifier==null ? 0 : tenantIdentifier.hashCode() ); - // the collections are too complicated to incorporate into the hashcode. but they really - // aren't needed in the hashcode calculation - they are handled in `#equals` and the calculation - // without them is a good hashing code. - // - // todo (6.0) : maybe even just base it on `sqlQueryString`? - + result = 37 * result + parameterBindingsMemento.hashCode(); + result = 37 * result + ( enabledFilterNames == null ? 0 : enabledFilterNames.hashCode() ); return result; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingsImpl.java b/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingsImpl.java index ca8fc5ec50..9d23805a29 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/internal/QueryParameterBindingsImpl.java @@ -186,7 +186,7 @@ public class QueryParameterBindingsImpl implements QueryParameterBindings { ? javaType.extractHashCode( bindValue ) : 0; - hashCode = 31 * hashCode + valueHashCode; + hashCode = 37 * hashCode + valueHashCode; } } else { @@ -199,7 +199,7 @@ public class QueryParameterBindingsImpl implements QueryParameterBindings { ? javaType.extractHashCode( bindValue ) : 0; - hashCode = 31 * hashCode + valueHashCode; + hashCode = 37 * hashCode + valueHashCode; } }