use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project robo4j by Robo4J.
the class PersistenceContextBuilder method build.
public PersistenceContextBuilder build() {
PersistenceDescriptorFactory persistenceDescriptorFactory = new PersistenceDescriptorFactory();
PersistenceUnitInfo persistenceUnitInfo = persistenceDescriptorFactory.get(RoboClassLoader.getInstance().getClassLoader(), sourceType, packages);
PersistenceUnitDescriptor persistenceUnitDescriptor = new PersistenceUnitInfoDescriptor(persistenceUnitInfo);
EntityManagerFactoryBuilder builder = new EntityManagerFactoryBuilderImpl(persistenceUnitDescriptor, new HashMap<>());
registeredClasses = persistenceDescriptorFactory.registeredClasses();
dataSourceContext = new DataSourceProxy(builder.build());
return this;
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project hibernate-orm by hibernate.
the class ConfigurationTest method buildMetadata.
@SuppressWarnings("unchecked")
private MetadataImplementor buildMetadata(SharedCacheMode mode) {
Map settings = new HashMap();
settings.put(AvailableSettings.SHARED_CACHE_MODE, mode);
settings.put(Environment.CACHE_REGION_FACTORY, CustomRegionFactory.class.getName());
settings.put(AvailableSettings.LOADED_CLASSES, Arrays.asList(ExplicitlyCacheableEntity.class, ExplicitlyNonCacheableEntity.class, NoCacheableAnnotationEntity.class));
PersistenceUnitInfoAdapter adapter = new PersistenceUnitInfoAdapter();
final EntityManagerFactoryBuilderImpl emfb = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, settings);
emf = emfb.build();
return emfb.getMetadata();
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project hibernate-orm by hibernate.
the class ConfigurationObjectSettingTest method testContainerBootstrapValidationMode.
@Test
public void testContainerBootstrapValidationMode() {
// first, via the integration vars
PersistenceUnitInfoAdapter empty = new PersistenceUnitInfoAdapter();
{
// as object
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.VALIDATION_MODE, ValidationMode.CALLBACK));
assertEquals(ValidationMode.CALLBACK, builder.getConfigurationValues().get(AvailableSettings.VALIDATION_MODE));
}
{
// as string
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.VALIDATION_MODE, ValidationMode.CALLBACK.name()));
assertEquals(ValidationMode.CALLBACK.name(), builder.getConfigurationValues().get(AvailableSettings.VALIDATION_MODE));
}
// next, via the PUI
PersistenceUnitInfoAdapter adapter = new PersistenceUnitInfoAdapter() {
@Override
public ValidationMode getValidationMode() {
return ValidationMode.CALLBACK;
}
};
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, null);
assertEquals(ValidationMode.CALLBACK, builder.getConfigurationValues().get(AvailableSettings.VALIDATION_MODE));
}
// via both, integration vars should take precedence
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, Collections.singletonMap(AvailableSettings.VALIDATION_MODE, ValidationMode.NONE));
assertEquals(ValidationMode.NONE, builder.getConfigurationValues().get(AvailableSettings.VALIDATION_MODE));
}
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project jbosstools-hibernate by jbosstools.
the class JpaConfiguration method getMetadata.
public Metadata getMetadata() {
if (metadata == null) {
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = HibernateToolsPersistenceProvider.createEntityManagerFactoryBuilder(persistenceUnit, getProperties());
EntityManagerFactory entityManagerFactory = entityManagerFactoryBuilder.build();
metadata = entityManagerFactoryBuilder.getMetadata();
getProperties().putAll(entityManagerFactory.getProperties());
}
return metadata;
}
use of org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl in project jbosstools-hibernate by jbosstools.
the class JpaConfiguration method initialize.
void initialize() {
EntityManagerFactoryBuilderImpl entityManagerFactoryBuilder = HibernateToolsPersistenceProvider.createEntityManagerFactoryBuilder(persistenceUnit, getProperties());
EntityManagerFactory entityManagerFactory = entityManagerFactoryBuilder.build();
sessionFactory = (SessionFactory) entityManagerFactory;
metadata = entityManagerFactoryBuilder.getMetadata();
getProperties().putAll(entityManagerFactory.getProperties());
}
Aggregations