From bae98ffaccf55c78bb1eb39b1e249f9b8ae92726 Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Mon, 3 Dec 2018 15:27:53 +0100 Subject: [PATCH] HHH-13138 By default, pass the class loader of the test to the EMF Not doing it causes issues when using the BytecodeEnhancerRunner which introduces an enhancing class loader. We could do it on a per test basis but it's easier to do it once and for all. And it can still be overridden anyway. --- .../jpa/test/BaseEntityManagerFunctionalTestCase.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java index 7a0ecd4ca9..4f0648baac 100644 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java +++ b/hibernate-core/src/test/java/org/hibernate/jpa/test/BaseEntityManagerFunctionalTestCase.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; + import javax.persistence.EntityManager; import javax.persistence.SharedCacheMode; import javax.persistence.ValidationMode; @@ -21,20 +22,17 @@ import javax.persistence.spi.PersistenceUnitTransactionType; import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; import org.hibernate.bytecode.enhance.spi.EnhancementContext; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Environment; import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.jpa.AvailableSettings; import org.hibernate.jpa.HibernatePersistenceProvider; import org.hibernate.jpa.boot.spi.Bootstrap; import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor; - import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.After; import org.junit.Before; -import org.jboss.logging.Logger; - /** * A base class for all ejb tests. * @@ -209,6 +207,8 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa Map config = Environment.getProperties(); ArrayList classes = new ArrayList(); + config.put( AvailableSettings.CLASSLOADERS, getClass().getClassLoader() ); + classes.addAll( Arrays.asList( getAnnotatedClasses() ) ); config.put( AvailableSettings.LOADED_CLASSES, classes ); for ( Map.Entry entry : getCachedClasses().entrySet() ) {