HHH-15728 Improve query cache key hash code to reduce collisions
This commit is contained in:
parent
68324b9297
commit
7d9ffc6158
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue