FileDocCategorySizeDatePackage
CacheKey.javaAPI DocHibernate 3.2.52073Wed May 09 12:36:08 BST 2007org.hibernate.cache

CacheKey

public class CacheKey extends Object implements Serializable
Allows multiple entity classes / collection roles to be stored in the same cache region. Also allows for composite keys which do not properly implement equals()/hashCode().
author
Gavin King

Fields Summary
private final Serializable
key
private final org.hibernate.type.Type
type
private final String
entityOrRoleName
private final org.hibernate.EntityMode
entityMode
private final int
hashCode
Constructors Summary
public CacheKey(Serializable id, org.hibernate.type.Type type, String entityOrRoleName, org.hibernate.EntityMode entityMode, org.hibernate.engine.SessionFactoryImplementor factory)
Construct a new key for a collection or entity instance. Note that an entity name should always be the root entity name, not a subclass entity name.

param
id The identifier associated with the cached data
param
type The Hibernate type mapping
param
entityOrRoleName The entity or collection-role name.
param
entityMode The entiyt mode of the originating session
param
factory The session factory for which we are caching

		this.key = id;
		this.type = type;
		this.entityOrRoleName = entityOrRoleName;
		this.entityMode = entityMode;
		hashCode = type.getHashCode( key, entityMode, factory );
	
Methods Summary
public booleanequals(java.lang.Object other)

		if ( !(other instanceof CacheKey) ) return false;
		CacheKey that = (CacheKey) other;
		return entityOrRoleName.equals( that.entityOrRoleName )
				&& type.isEqual( key, that.key, entityMode );
	
public java.lang.StringgetEntityOrRoleName()

		return entityOrRoleName;
	
public java.io.SerializablegetKey()

		return key;
	
public inthashCode()

		return hashCode;
	
public java.lang.StringtoString()

		return entityOrRoleName + '#" + key.toString();//"CacheKey#" + type.toString(key, sf);