use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project jbosstools-hibernate by jbosstools.
the class HibernateToolsPersistenceProviderTest method testCreateEntityManagerFactoryBuilder.
@Test
public void testCreateEntityManagerFactoryBuilder() {
Properties properties = new Properties();
properties.put("foo", "bar");
assertNull(HibernateToolsPersistenceProvider.createEntityManagerFactoryBuilder("barfoo", properties));
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = HibernateToolsPersistenceProvider.createEntityManagerFactoryBuilder("foobar", properties);
assertNotNull(entityManagerFactoryBuilder);
assertEquals("bar", entityManagerFactoryBuilder.getConfigurationValues().get("foo"));
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project cas by apereo.
the class CasHibernatePersistenceProvider method createContainerEntityManagerFactory.
@Override
public EntityManagerFactory createContainerEntityManagerFactory(final PersistenceUnitInfo info, final Map properties) {
val filtered = CollectionUtils.intersection(info.getManagedClassNames(), providerContext.getIncludeEntityClasses());
if (info.getManagedClassNames().isEmpty() && !providerContext.getIncludeEntityClasses().isEmpty()) {
filtered.addAll(providerContext.getIncludeEntityClasses());
}
LOGGER.trace("Filtered entity classes for entity manager are [{}]", filtered);
val mergedClassesAndPackages = new HashSet<String>(filtered);
if (info instanceof SmartPersistenceUnitInfo) {
mergedClassesAndPackages.addAll(((SmartPersistenceUnitInfo) info).getManagedPackages());
}
val persistenceUnit = new CasPersistenceUnitInfoDescriptor(info, new ArrayList<>(mergedClassesAndPackages));
return new EntityManagerFactoryBuilderImpl(persistenceUnit, properties).build();
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project hibernate-orm by hibernate.
the class ConfigurationObjectSettingTest method testContainerBootstrapSharedCacheMode.
@Test
public void testContainerBootstrapSharedCacheMode() {
// first, via the integration vars
PersistenceUnitInfoAdapter empty = new PersistenceUnitInfoAdapter();
{
// as object
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
{
// as string
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE.name()));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE.name(), builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
// next, via the PUI
PersistenceUnitInfoAdapter adapter = new PersistenceUnitInfoAdapter() {
@Override
public SharedCacheMode getSharedCacheMode() {
return SharedCacheMode.ENABLE_SELECTIVE;
}
};
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, null);
assertEquals(SharedCacheMode.ENABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
// via both, integration vars should take precedence
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project jOOQ by jOOQ.
the class AttributeConverterExtractor method initEntityManagerFactory.
private final EntityManagerFactory initEntityManagerFactory() {
PersistenceUnitInfo persistenceUnitInfo = persistenceUnitInfo(getClass().getSimpleName());
Map<String, Object> configuration = new HashMap<>();
configuration.put("hibernate.integrator_provider", integratorProvider());
configuration.put("hibernate.hbm2ddl.auto", "none");
configuration.put(AvailableSettings.CONNECTION_PROVIDER, database.connectionProvider());
PersistenceUnitInfoDescriptor descriptor = new PersistenceUnitInfoDescriptor(persistenceUnitInfo);
return new EntityManagerFactoryBuilderImpl(descriptor, configuration).build();
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project hibernate-orm by hibernate.
the class BootstrapTest method test_bootstrap_bootstrap_native_EntityManagerFactory_example.
@Test
public void test_bootstrap_bootstrap_native_EntityManagerFactory_example() {
try {
// tag::bootstrap-native-EntityManagerFactory-example[]
String persistenceUnitName = "CRM";
List<String> entityClassNames = new ArrayList<>();
Properties properties = new Properties();
PersistenceUnitInfoImpl persistenceUnitInfo = new PersistenceUnitInfoImpl(persistenceUnitName, entityClassNames, properties);
Map<String, Object> integrationSettings = new HashMap<>();
integrationSettings.put(AvailableSettings.INTERCEPTOR, new CustomSessionFactoryInterceptor());
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = new EntityManagerFactoryBuilderImpl(new PersistenceUnitInfoDescriptor(persistenceUnitInfo), integrationSettings);
EntityManagerFactory emf = entityManagerFactoryBuilder.build();
// end::bootstrap-native-EntityManagerFactory-example[]
} catch (Exception ignore) {
}
}
Aggregations