HHH-13853 - Pass the merged Integration settings and Persistence Unit properties to buildBootstrapServiceRegistry
This commit is contained in:
parent
015d1e019f
commit
9084ce497e
|
@ -196,8 +196,19 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil
|
|||
integrationSettings = Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map mergedIntegrationSettings = null;
|
||||
Properties properties = persistenceUnit.getProperties();
|
||||
if ( properties != null ) {
|
||||
mergedIntegrationSettings = new HashMap( persistenceUnit.getProperties() );
|
||||
mergedIntegrationSettings.putAll( integrationSettings );
|
||||
}
|
||||
|
||||
// Build the boot-strap service registry, which mainly handles class loader interactions
|
||||
final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry( integrationSettings, providedClassLoader, providedClassLoaderService);
|
||||
final BootstrapServiceRegistry bsr = buildBootstrapServiceRegistry(
|
||||
mergedIntegrationSettings != null ? mergedIntegrationSettings : integrationSettings,
|
||||
providedClassLoader,
|
||||
providedClassLoaderService
|
||||
);
|
||||
|
||||
// merge configuration sources and build the "standard" service registry
|
||||
final StandardServiceRegistryBuilder ssrBuilder = StandardServiceRegistryBuilder.forJpa( bsr );
|
||||
|
|
|
@ -80,7 +80,7 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
|
|||
afterEntityManagerFactoryBuilt();
|
||||
}
|
||||
|
||||
private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
protected PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
return new TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.jpa.test.integrationprovider;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHHH-13853")
|
||||
public class IntegrationProviderSettingByClassUsingPropertiesTest extends BaseEntityManagerFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
Person.class
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
doInJPA( this::entityManagerFactory, entityManager -> {
|
||||
List<PersonDto> dtos = entityManager.createQuery(
|
||||
"select new PersonDto(id, name) " +
|
||||
"from Person", PersonDto.class )
|
||||
.getResultList();
|
||||
} );
|
||||
}
|
||||
|
||||
protected PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
return new TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() ) {
|
||||
@Override
|
||||
public Properties getProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.put(
|
||||
EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER,
|
||||
DtoIntegratorProvider.class.getName()
|
||||
);
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -154,10 +154,6 @@ public class JpaSchemaGeneratorTest extends BaseEntityManagerFunctionalTestCase
|
|||
}
|
||||
}
|
||||
|
||||
private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||
return new TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() );
|
||||
}
|
||||
|
||||
/* Disable hibernate schema export */
|
||||
@Override
|
||||
protected boolean createSchema() {
|
||||
|
|
Loading…
Reference in New Issue