HHH-16385 Ensure QueryKey is immutable and serializable
This commit is contained in:
parent
cdfa7a9bdc
commit
5293cdd235
|
@ -8,6 +8,7 @@ package org.hibernate.cache.spi;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ public class QueryKey implements Serializable {
|
||||||
private final Integer firstRow;
|
private final Integer firstRow;
|
||||||
private final Integer maxRows;
|
private final Integer maxRows;
|
||||||
private final String tenantIdentifier;
|
private final String tenantIdentifier;
|
||||||
private final Set<String> enabledFilterNames;
|
private final String[] enabledFilterNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For performance reasons, the hashCode is cached; however, it is marked transient so that it can be
|
* For performance reasons, the hashCode is cached; however, it is marked transient so that it can be
|
||||||
|
@ -85,7 +86,7 @@ public class QueryKey implements Serializable {
|
||||||
this.firstRow = firstRow;
|
this.firstRow = firstRow;
|
||||||
this.maxRows = maxRows;
|
this.maxRows = maxRows;
|
||||||
this.tenantIdentifier = tenantIdentifier;
|
this.tenantIdentifier = tenantIdentifier;
|
||||||
this.enabledFilterNames = enabledFilterNames;
|
this.enabledFilterNames = enabledFilterNames.toArray( String[]::new );
|
||||||
this.hashCode = generateHashCode();
|
this.hashCode = generateHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +111,7 @@ public class QueryKey implements Serializable {
|
||||||
// result = 37 * result + ( maxRows==null ? 0 : maxRows );
|
// result = 37 * result + ( maxRows==null ? 0 : maxRows );
|
||||||
result = 37 * result + ( tenantIdentifier==null ? 0 : tenantIdentifier.hashCode() );
|
result = 37 * result + ( tenantIdentifier==null ? 0 : tenantIdentifier.hashCode() );
|
||||||
result = 37 * result + parameterBindingsMemento.hashCode();
|
result = 37 * result + parameterBindingsMemento.hashCode();
|
||||||
result = 37 * result + ( enabledFilterNames == null ? 0 : enabledFilterNames.hashCode() );
|
result = 37 * result + Arrays.hashCode( enabledFilterNames );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +147,7 @@ public class QueryKey implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Objects.equals( enabledFilterNames, that.enabledFilterNames ) ) {
|
if ( ! Arrays.equals( enabledFilterNames, that.enabledFilterNames ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue