From 8ed1ed5159e5cb4669fd85dcdbb7a64bcf068f64 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 16 Feb 2022 15:19:05 +0100 Subject: [PATCH] Re-enabled additional tests --- .../test/loading/multiLoad/MultiLoadTest.java | 28 ++++++------------- .../orm/junit/DomainModelExtension.java | 9 +++++- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java index 043d84598e..45d45eae51 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/multiLoad/MultiLoadTest.java @@ -23,8 +23,6 @@ import org.hibernate.stat.Statistics; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.FailureExpected; -import org.hibernate.testing.orm.junit.NotImplementedYet; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -206,7 +204,6 @@ public class MultiLoadTest { @Test @TestForIssue(jiraKey = "HHH-12944") - @NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented") public void testMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) { final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); @@ -261,7 +258,6 @@ public class MultiLoadTest { @Test @TestForIssue(jiraKey = "HHH-12944") - @NotImplementedYet(strict = false, reason = "Caching/CacheMode supported not yet implemented") public void testUnorderedMultiLoadFrom2ndLevelCache(SessionFactoryScope scope) { final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); @@ -450,25 +446,19 @@ public class MultiLoadTest { } @Test - @NotImplementedYet(strict = false, reason = "CacheMode not yet implemented") public void testMultiLoadWithCacheModeIgnore(SessionFactoryScope scope) { // do the multi-load, telling Hibernate to IGNORE the L2 cache - // the end result should be that the cache is (still) empty afterwards - scope.inTransaction( - session -> { - session.getTransaction().begin(); - List list = session.byMultipleIds( SimpleEntity.class ) - .with( CacheMode.IGNORE ) - .multiLoad( ids( 56 ) ); - session.getTransaction().commit(); - session.close(); - - assertEquals( 56, list.size() ); - for ( SimpleEntity entity : list ) { - assertFalse( scope.getSessionFactory().getCache().containsEntity( SimpleEntity.class, entity.getId() ) ); - } - } + List list = scope.fromTransaction( + session -> + session.byMultipleIds( SimpleEntity.class ) + .with( CacheMode.IGNORE ) + .multiLoad( ids( 56 ) ) ); + assertEquals( 56, list.size() ); + for ( SimpleEntity entity : list ) { + assertFalse( scope.getSessionFactory().getCache().containsEntity( SimpleEntity.class, entity.getId() ) ); + } } @Test diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java index 6fe884d30b..8b20568152 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/DomainModelExtension.java @@ -16,7 +16,7 @@ import org.hibernate.boot.internal.MetadataBuilderImpl; import org.hibernate.boot.model.TypeContributor; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.spi.MetadataImplementor; -import org.hibernate.mapping.BasicValue; +import org.hibernate.cache.spi.access.AccessType; import org.hibernate.mapping.Collection; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; @@ -32,6 +32,8 @@ import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; import org.junit.jupiter.api.extension.TestInstancePostProcessor; import org.junit.platform.commons.support.AnnotationSupport; +import jakarta.persistence.SharedCacheMode; + /** * hibernate-testing implementation of a few JUnit5 contracts to support SessionFactory-based testing, * including argument injection (or see {@link DomainModelScopeAware}) @@ -133,6 +135,11 @@ public class DomainModelExtension contributor.contribute( metadataBuilder, serviceRegistry ); } + final SharedCacheMode sharedCacheMode = domainModelAnnotation.sharedCacheMode(); + final AccessType accessType = domainModelAnnotation.accessType(); + metadataBuilder.applySharedCacheMode( sharedCacheMode ); + metadataBuilder.applyAccessType( accessType ); + MetadataImplementor metadataImplementor = metadataBuilder.build(); applyCacheSettings( metadataImplementor,