HHH-7509 NPE regression in second level cache

This commit is contained in:
Strong Liu 2012-08-09 14:43:11 +08:00
parent 8e73bb056e
commit fae0d3f498
2 changed files with 11 additions and 5 deletions

View File

@ -87,15 +87,18 @@ public class CacheKey implements Serializable {
@Override
public boolean equals(Object other) {
if ( other == null ) {
return false;
}
if ( this == other ) {
return true;
}
if ( !(other instanceof CacheKey) || hashCode != other.hashCode()) {
if ( hashCode != other.hashCode() || !( other instanceof CacheKey ) ) {
//hashCode is part of this check since it is pre-calculated and hash must match for equals to be true
return false;
}
CacheKey that = (CacheKey) other;
return entityOrRoleName.equals( that.entityOrRoleName ) &&
return EqualsHelper.equals( entityOrRoleName, that.entityOrRoleName ) &&
type.isEqual( key, that.key ) &&
EqualsHelper.equals( tenantId, that.tenantId );
}

View File

@ -137,17 +137,20 @@ public class NaturalIdCacheKey implements Serializable {
@Override
public boolean equals(Object o) {
if ( o == null ) {
return false;
}
if ( this == o ) {
return true;
}
if ( !(o instanceof NaturalIdCacheKey) || hashCode != o.hashCode() ) {
if ( hashCode != o.hashCode() || !( o instanceof NaturalIdCacheKey ) ) {
//hashCode is part of this check since it is pre-calculated and hash must match for equals to be true
return false;
}
final NaturalIdCacheKey other = (NaturalIdCacheKey) o;
return entityName.equals( other.entityName )
return EqualsHelper.equals( entityName, other.entityName )
&& EqualsHelper.equals( tenantId, other.tenantId )
&& Arrays.deepEquals( this.naturalIdValues, other.naturalIdValues );
}