Search in sources :

Example 11 with PersistenceUnitDescriptorAdapter

use of org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.

the class AbstractEntityManagerTest method init.

protected void init(boolean audited, String auditStrategy) throws IOException {
    this.audited = audited;
    Properties configurationProperties = new Properties();
    configurationProperties.putAll(Environment.getProperties());
    if (!audited) {
        configurationProperties.setProperty(EnversIntegrator.AUTO_REGISTER, "false");
    }
    if (createSchema()) {
        configurationProperties.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
        configurationProperties.setProperty(Environment.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
        configurationProperties.setProperty(EnversSettings.USE_REVISION_ENTITY_WITH_NATIVE_ID, "false");
    }
    if (auditStrategy != null && !"".equals(auditStrategy)) {
        configurationProperties.setProperty("org.hibernate.envers.audit_strategy", auditStrategy);
    }
    addConfigurationProperties(configurationProperties);
    configurationProperties.put(AvailableSettings.LOADED_CLASSES, Arrays.asList(getAnnotatedClasses()));
    entityManagerFactoryBuilder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(new PersistenceUnitDescriptorAdapter(), configurationProperties);
    emf = entityManagerFactoryBuilder.build().unwrap(HibernateEntityManagerFactory.class);
    serviceRegistry = (StandardServiceRegistryImpl) emf.getSessionFactory().getServiceRegistry().getParentServiceRegistry();
    newEntityManager();
}
Also used : HibernateEntityManagerFactory(org.hibernate.jpa.HibernateEntityManagerFactory) Properties(java.util.Properties) PersistenceUnitDescriptorAdapter(org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter)

Aggregations

PersistenceUnitDescriptorAdapter (org.hibernate.jpa.test.PersistenceUnitDescriptorAdapter)11 Map (java.util.Map)10 EntityManagerFactory (javax.persistence.EntityManagerFactory)10 Test (org.junit.Test)10 EntityManager (javax.persistence.EntityManager)7 Item (org.hibernate.jpa.test.Item)6 HashMap (java.util.HashMap)2 TestForIssue (org.hibernate.testing.TestForIssue)2 Properties (java.util.Properties)1 PersistenceException (javax.persistence.PersistenceException)1 RollbackException (javax.persistence.RollbackException)1 HibernateEntityManagerFactory (org.hibernate.jpa.HibernateEntityManagerFactory)1 FailureExpected (org.hibernate.testing.FailureExpected)1