HHH-14443 Add hashcode to ObjectTypeCacheEntry, so query cache can do a successfull lookup for queryies with AnyTypes

This commit is contained in:
Francois van Delft 2021-02-08 12:17:38 +01:00 committed by Sanne Grinovero
parent a90aaa48b4
commit de3f3c1d74
1 changed files with 14 additions and 0 deletions

View File

@ -13,6 +13,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.hibernate.EntityMode;
@ -519,5 +520,18 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
this.entityName = entityName;
this.id = id;
}
public int hashCode() {
return Objects.hash(entityName, id);
}
public boolean equals(Object object) {
if (object instanceof ObjectTypeCacheEntry) {
ObjectTypeCacheEntry objectTypeCacheEntry = (ObjectTypeCacheEntry)object;
return Objects.equals(objectTypeCacheEntry.entityName, entityName) && Objects.equals(objectTypeCacheEntry.id, id);
}
return false;
}
}
}