mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 06:49:09 +00:00
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 @@ private EntityManagerFactoryBuilderImpl(
|
|||||||
integrationSettings = Collections.emptyMap();
|
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
|
// 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
|
// merge configuration sources and build the "standard" service registry
|
||||||
final StandardServiceRegistryBuilder ssrBuilder = StandardServiceRegistryBuilder.forJpa( bsr );
|
final StandardServiceRegistryBuilder ssrBuilder = StandardServiceRegistryBuilder.forJpa( bsr );
|
||||||
|
@ -80,7 +80,7 @@ public void buildEntityManagerFactory() {
|
|||||||
afterEntityManagerFactoryBuilt();
|
afterEntityManagerFactoryBuilt();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
protected PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
||||||
return new TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() );
|
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 @@ private void doTest(Map settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PersistenceUnitDescriptor buildPersistenceUnitDescriptor() {
|
|
||||||
return new TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disable hibernate schema export */
|
/* Disable hibernate schema export */
|
||||||
@Override
|
@Override
|
||||||
protected boolean createSchema() {
|
protected boolean createSchema() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user