[hibernate-commits] Hibernate SVN: r11499 - trunk/Hibernate3/src/org/hibernate/cache.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed May 9 13:35:55 EDT 2007
Author: steve.ebersole at jboss.com
Date: 2007-05-09 13:35:55 -0400 (Wed, 09 May 2007)
New Revision: 11499
Modified:
trunk/Hibernate3/src/org/hibernate/cache/CacheKey.java
Log:
HHH-2316 : CacheKey.equals()
Modified: trunk/Hibernate3/src/org/hibernate/cache/CacheKey.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/cache/CacheKey.java 2007-05-09 14:55:16 UTC (rev 11498)
+++ trunk/Hibernate3/src/org/hibernate/cache/CacheKey.java 2007-05-09 17:35:55 UTC (rev 11499)
@@ -8,10 +8,10 @@
import org.hibernate.type.Type;
/**
- * Allows multiple entity classes / collection roles to be
- * stored in the same cache region. Also allows for composite
+ * 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
*/
public class CacheKey implements Serializable {
@@ -20,24 +20,29 @@
private final String entityOrRoleName;
private final EntityMode entityMode;
private final int hashCode;
-
+
/**
* Construct a new key for a collection or entity instance.
- * Note that an entity name should always be the root entity
+ * 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
*/
public CacheKey(
- final Serializable id,
- final Type type,
- final String entityOrRoleName,
- final EntityMode entityMode,
- final SessionFactoryImplementor factory
- ) {
+ final Serializable id,
+ final Type type,
+ final String entityOrRoleName,
+ final EntityMode entityMode,
+ final SessionFactoryImplementor factory) {
this.key = id;
this.type = type;
this.entityOrRoleName = entityOrRoleName;
this.entityMode = entityMode;
- hashCode = type.getHashCode(key, entityMode, factory);
+ hashCode = type.getHashCode( key, entityMode, factory );
}
//Mainly for OSCache
@@ -48,18 +53,18 @@
public boolean equals(Object other) {
if ( !(other instanceof CacheKey) ) return false;
CacheKey that = (CacheKey) other;
- return type.isEqual(key, that.key, entityMode) &&
- entityOrRoleName.equals(that.entityOrRoleName);
+ return entityOrRoleName.equals( that.entityOrRoleName )
+ && type.isEqual( key, that.key, entityMode );
}
public int hashCode() {
return hashCode;
}
-
+
public Serializable getKey() {
return key;
}
-
+
public String getEntityOrRoleName() {
return entityOrRoleName;
}
More information about the hibernate-commits
mailing list