You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Mathew, Sijo " <si...@citi.com> on 2008/11/14 20:44:23 UTC

Generation of hash key uses IdentityHashCode (in the class CacheKey)

Why are we using identityHashCode (code snippet given below) to build
the hash key for the object to be put in the Cache? Is there any config
setting to prevent this?

In distributed Caching scenario, this will create different hash keys
for the same query with the exact same parameters. This also means that,
the existing OSCACHE implementation cannot be used in a distributed
scenario.

//from the class SqlMapExecutorDelegate
public int hashCode() {
    CacheKey key = new CacheKey();
    if (txManager != null) {
      key.update(txManager);
      if (txManager.getConfig().getDataSource() != null) {
        key.update(txManager.getConfig().getDataSource());
      }
    }
    key.update(System.identityHashCode(this));
    return key.hashCode();
  }

Regards
Sijo Mathew