From 0023dc695dc82938f6838138180545c750ac47f8 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 13 Apr 2011 23:16:06 -0500 Subject: [PATCH] HHH-6093 - Account for tenant identifier on QueryKey --- .../src/main/java/org/hibernate/cache/QueryKey.java | 9 ++++++++- .../src/test/java/org/hibernate/cache/QueryKeyTest.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cache/QueryKey.java b/hibernate-core/src/main/java/org/hibernate/cache/QueryKey.java index 1f577593f7..08322b33a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/QueryKey.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/QueryKey.java @@ -53,6 +53,7 @@ public class QueryKey implements Serializable { private final Integer firstRow; private final Integer maxRows; private final EntityMode entityMode; + private final String tenantIdentifier; private final Set filterKeys; // the user provided resulttransformer, not the one used with "select new". Here to avoid mangling @@ -136,6 +137,7 @@ public class QueryKey implements Serializable { maxRows, filterKeys, session.getEntityMode(), + session.getTenantIdentifier(), customTransformer ); } @@ -162,6 +164,7 @@ public class QueryKey implements Serializable { Integer maxRows, Set filterKeys, EntityMode entityMode, + String tenantIdentifier, CacheableResultTransformer customTransformer) { this.sqlQueryString = sqlQueryString; this.positionalParameterTypes = positionalParameterTypes; @@ -170,6 +173,7 @@ public class QueryKey implements Serializable { this.firstRow = firstRow; this.maxRows = maxRows; this.entityMode = entityMode; + this.tenantIdentifier = tenantIdentifier; this.filterKeys = filterKeys; this.customTransformer = customTransformer; this.hashCode = generateHashCode(); @@ -202,6 +206,7 @@ public class QueryKey implements Serializable { result = 37 * result + ( namedParameters==null ? 0 : namedParameters.hashCode() ); result = 37 * result + ( filterKeys ==null ? 0 : filterKeys.hashCode() ); result = 37 * result + ( customTransformer==null ? 0 : customTransformer.hashCode() ); + result = 37 * result + ( tenantIdentifier==null ? 0 : tenantIdentifier.hashCode() ); result = 37 * result + sqlQueryString.hashCode(); return result; } @@ -247,7 +252,9 @@ public class QueryKey implements Serializable { } return EqualsHelper.equals( filterKeys, that.filterKeys ) - && EqualsHelper.equals( namedParameters, that.namedParameters ); + && EqualsHelper.equals( namedParameters, that.namedParameters ) + && EqualsHelper.equals( entityMode, that.entityMode ) + && EqualsHelper.equals( tenantIdentifier, that.tenantIdentifier ); } /** diff --git a/hibernate-core/src/test/java/org/hibernate/cache/QueryKeyTest.java b/hibernate-core/src/test/java/org/hibernate/cache/QueryKeyTest.java index a81a7a83c8..c07e6947b2 100644 --- a/hibernate-core/src/test/java/org/hibernate/cache/QueryKeyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/cache/QueryKeyTest.java @@ -236,6 +236,7 @@ public class QueryKeyTest extends BaseUnitTestCase { null, // maxRows selection Collections.EMPTY_SET, // filter keys EntityMode.POJO, // entity mode + null, // tenantIdentifier resultTransformer // the result transformer ); }