use of org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder in project hibernate-orm by hibernate.
the class MappingClassMoreThanOnceTest method testBootstrapWithClassMappedMOreThanOnce.
/**
* Tests that an entity manager can be created when a class is mapped more than once.
*/
@Test
@TestForIssue(jiraKey = "HHH-8775")
public // @FailureExpected(jiraKey = "HHH-8775")
void testBootstrapWithClassMappedMOreThanOnce() {
Map settings = new HashMap();
settings.put(AvailableSettings.HBXML_FILES, "org/hibernate/jpa/test/callbacks/hbmxml/ClassMappedMoreThanOnce.hbm.xml");
final EntityManagerFactoryBuilder builder = Bootstrap.getEntityManagerFactoryBuilder(new BaseEntityManagerFunctionalTestCase.TestingPersistenceUnitDescriptorImpl(getClass().getSimpleName()), settings);
HibernateEntityManagerFactory emf = null;
try {
emf = builder.build().unwrap(HibernateEntityManagerFactory.class);
} finally {
if (emf != null) {
try {
emf.close();
} catch (Exception ignore) {
}
}
}
}
use of org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder in project hibernate-orm by hibernate.
the class HibernatePersistenceProvider method generateSchema.
@Override
public void generateSchema(PersistenceUnitInfo info, Map map) {
log.tracef("Starting generateSchema : PUI.name=%s", info.getPersistenceUnitName());
final EntityManagerFactoryBuilder builder = getEntityManagerFactoryBuilder(info, map);
builder.generateSchema();
}
use of org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder in project hibernate-orm by hibernate.
the class JpaSchemaGeneratorTest method doTest.
@SuppressWarnings("unchecked")
private void doTest(Map settings) {
// We want a fresh db after emf close
// Unfortunately we have to use this dirty hack because the db seems not to be closed otherwise
settings.put("hibernate.connection.url", "jdbc:h2:mem:db-schemagen" + schemagenNumber++ + ";MVCC=TRUE;LOCK_TIMEOUT=10000");
EntityManagerFactoryBuilder emfb = Bootstrap.getEntityManagerFactoryBuilder(buildPersistenceUnitDescriptor(), settings);
EntityManagerFactory emf = emfb.build();
try {
EntityManager em = emf.createEntityManager();
try {
Assert.assertNotNull(em.find(Item.class, encodedName()));
} finally {
em.close();
}
} finally {
emf.close();
emfb.cancel();
}
}
use of org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder in project hibernate-orm by hibernate.
the class ValidatorFactory2PhaseInjectionTest method testInjectionAvailabilityFromEmf.
@Test
public void testInjectionAvailabilityFromEmf() {
EntityManagerFactoryBuilder emfb = Bootstrap.getEntityManagerFactoryBuilder(new JpaXsdVersionsTest.PersistenceUnitInfoImpl("my-test") {
@Override
public URL getPersistenceUnitRootUrl() {
// just get any known url...
return HibernatePersistenceProvider.class.getResource("/org/hibernate/jpa/persistence_1_0.xsd");
}
}, Collections.emptyMap());
emfb.withValidatorFactory(vf);
EntityManagerFactory emf = emfb.build();
try {
assertSame(vf, emf.getProperties().get(AvailableSettings.VALIDATION_FACTORY));
} finally {
emf.close();
}
}
Aggregations