Hello,
A change has been to made HashtableCache in RC2.
in RC1 :
public object Get( object key )
{
return hashtable[ key.ToString() ];
}
in RC2
public object Get( object key )
{
return hashtable[ key ];
}
if key is a CacheKey then the ToString() method was (in RC1) based on
CacheKey.entityOrRoleName + CacheKey.Key.ToString() to build the ID for the cache.
(CacheKey)
public override string ToString()
{
return (this.entityOrRoleName + '#' + this.key.ToString());
}
now in RC2, it is only based on CacheKey.GetHashCode() which is setup in the constructor of CacheKey
public CacheKey(object id, IType type, string entityOrRoleName, ISessionFactoryImplementor factory)
{
this.key = id;
this.type = type;
this.entityOrRoleName = entityOrRoleName;
this.hashCode = type.GetHashCode(this.key, factory);
}
As we see, the CacheKey.entityOrRoleName is no more used to determine the ID for the cache.
=> Conclusion : if I have 2 entities of 2 different classes with the same identifier in the cache, these 2 entities have the same ID in the cache (they share the same key!) => Problem
Thanks for your help !
|