From 973437cecae0affc23bbd871ca8dd37a943cd2a0 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 14 Mar 2023 19:04:40 +0100 Subject: [PATCH] HHH-16281 Inconsistent Behaivor of L2 cache between Hibernate 5 and 6 --- .../cache/MutableCacheKeyBuilder.java | 31 ++++++++++ .../metamodel/mapping/BasicValuedMapping.java | 31 ++++++++++ .../hibernate/metamodel/mapping/Bindable.java | 53 ++++++++-------- .../mapping/EmbeddableValuedModelPart.java | 6 ++ .../mapping/EntityValuedModelPart.java | 6 ++ .../internal/AbstractEmbeddableMapping.java | 15 ++++- .../internal/AnyDiscriminatorPart.java | 11 +++- .../internal/BasicAttributeMapping.java | 6 +- .../BasicEntityIdentifierMappingImpl.java | 6 ++ .../internal/BasicValuedCollectionPart.java | 6 +- .../CollectionIdentifierDescriptorImpl.java | 6 ++ .../internal/CompoundNaturalIdMapping.java | 13 ++++ ...criminatedAssociationAttributeMapping.java | 18 ++++++ .../internal/DiscriminatedCollectionPart.java | 6 ++ .../EmbeddedForeignKeyDescriptor.java | 6 ++ .../EmbeddedIdentifierMappingImpl.java | 14 +---- .../internal/EntityCollectionPart.java | 7 +++ .../internal/EntityRowIdMappingImpl.java | 6 ++ .../internal/EntityVersionMappingImpl.java | 6 ++ .../mapping/internal/IdClassEmbeddable.java | 13 +++- ...InverseNonAggregatedIdentifierMapping.java | 6 ++ .../NonAggregatedIdentifierMappingImpl.java | 6 ++ .../internal/OneToManyCollectionPart.java | 10 ---- .../internal/PluralAttributeMappingImpl.java | 8 ++- .../internal/SimpleForeignKeyDescriptor.java | 25 ++++++++ .../internal/SimpleNaturalIdMapping.java | 6 ++ .../internal/ToOneAttributeMapping.java | 6 ++ .../model/domain/internal/ArrayTupleType.java | 6 ++ .../TupleMappingModelExpressible.java | 8 +++ .../persister/entity/DiscriminatorType.java | 6 ++ .../persister/entity/EntityPersister.java | 9 +++ .../AnonymousTupleBasicValuedModelPart.java | 7 +++ ...onymousTupleEmbeddableValuedModelPart.java | 11 ++++ .../AnonymousTupleEntityValuedModelPart.java | 6 ++ .../AnonymousTupleTableGroupProducer.java | 6 ++ .../internal/QueryParameterBindingsImpl.java | 60 ++++++++++--------- .../tree/expression/EntityTypeLiteral.java | 6 ++ .../sql/ast/tree/expression/JdbcLiteral.java | 12 ++++ .../exec/internal/AbstractJdbcParameter.java | 20 +++++++ .../java/org/hibernate/type/CustomType.java | 29 +++++++++ .../java/ComponentArrayMutabilityPlan.java | 58 ------------------ .../type/descriptor/java/JavaType.java | 1 - .../descriptor/java/JavaTypedExpressible.java | 6 ++ .../internal/UserTypeJavaTypeWrapper.java | 35 ++++++++++- 44 files changed, 465 insertions(+), 154 deletions(-) create mode 100644 hibernate-core/src/main/java/org/hibernate/cache/MutableCacheKeyBuilder.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/type/descriptor/java/ComponentArrayMutabilityPlan.java diff --git a/hibernate-core/src/main/java/org/hibernate/cache/MutableCacheKeyBuilder.java b/hibernate-core/src/main/java/org/hibernate/cache/MutableCacheKeyBuilder.java new file mode 100644 index 0000000000..2cb526fe4f --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/cache/MutableCacheKeyBuilder.java @@ -0,0 +1,31 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later. + * See the lgpl.txt file in the root directory or . + */ +package org.hibernate.cache; + +import java.io.Serializable; + +import org.hibernate.cache.spi.QueryResultsCache; + +/** + * A builder that generates a Serializable Object to be used as a key into the {@linkplain QueryResultsCache + * query results cache}. + */ + +public interface MutableCacheKeyBuilder extends Serializable { + + void addValue(Object value); + + + void addHashCode(int hashCode); + + /** + * creates an Object to be used as a key into the {@linkplain QueryResultsCache + * query results cache}. + */ + Serializable build(); + +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedMapping.java index e3026f41ed..607f1a287a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedMapping.java @@ -6,9 +6,15 @@ */ package org.hibernate.metamodel.mapping; +import java.io.Serializable; import java.util.Collections; import java.util.List; +import org.hibernate.cache.MutableCacheKeyBuilder; +import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.type.descriptor.converter.spi.BasicValueConverter; +import org.hibernate.type.descriptor.java.JavaType; + /** * Any basic-typed ValueMapping. Generally this would be one of