-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Problem with HashTableCache in 1.2 RC2
PostPosted: Wed Apr 25, 2007 11:09 am 
Beginner
Beginner

Joined: Fri Jan 19, 2007 10:45 am
Posts: 23
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 !


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 25, 2007 11:28 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Of course they don't share the same key as long as they are not Equal()! The fact they have the same hash code means they just share the same bin of the hashtable.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.