use of org.hibernate.testing.orm.jpa.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.
the class PersisterClassProviderTest method testPersisterClassProvider.
@Test
public void testPersisterClassProvider() {
Map settings = SettingsGenerator.generateSettings(PersisterClassResolverInitiator.IMPL_NAME, GoofyPersisterClassProvider.class, AvailableSettings.LOADED_CLASSES, Arrays.asList(Bell.class));
try {
EntityManagerFactory entityManagerFactory = Bootstrap.getEntityManagerFactoryBuilder(new PersistenceUnitDescriptorAdapter(), settings).build();
entityManagerFactory.close();
} catch (PersistenceException e) {
Assertions.assertNotNull(e.getCause());
Assertions.assertNotNull(e.getCause().getCause());
Assertions.assertEquals(GoofyException.class, e.getCause().getCause().getClass());
}
}
use of org.hibernate.testing.orm.jpa.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.
the class MappedSuperclassType2Test method testMappedSuperclassAccessNoEntity.
@Test
@TestForIssue(jiraKey = "HHH-8534")
@FailureExpected(jiraKey = "HHH-8534")
public void testMappedSuperclassAccessNoEntity() {
// stupid? yes. tck does it? yes.
final PersistenceUnitDescriptorAdapter pu = new PersistenceUnitDescriptorAdapter() {
@Override
public List<String> getManagedClassNames() {
// pass in a MappedSuperclass that is not used in any entity hierarchy
return Arrays.asList(SomeMappedSuperclass.class.getName());
}
};
final Map settings = new HashMap();
settings.put(AvailableSettings.HBM2DDL_AUTO, "create-drop");
EntityManagerFactory emf = Bootstrap.getEntityManagerFactoryBuilder(pu, settings).build();
try {
ManagedType<SomeMappedSuperclass> type = emf.getMetamodel().managedType(SomeMappedSuperclass.class);
// the issue was in regards to throwing an exception, but also check for nullness
assertNotNull(type);
} finally {
emf.close();
}
}
use of org.hibernate.testing.orm.jpa.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.
the class TransactionCommitFailureTest method setUp.
@BeforeEach
public void setUp() {
// static variables need to be initialized before the EMF is set up, because they can be referenced during EMF setup via the connection provider.
transactionFailureTrigger = new AtomicBoolean();
connectionIsOpen = new AtomicBoolean();
final Map settings = basicSettings();
emf = Bootstrap.getEntityManagerFactoryBuilder(new PersistenceUnitDescriptorAdapter(), settings).build();
}
use of org.hibernate.testing.orm.jpa.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.
the class Hbm2ddlCreateOnlyTest method testColumnAnnotationWithExplicitReferenceToPrimaryTable.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
@TestForIssue(jiraKey = "HHH-12955")
public void testColumnAnnotationWithExplicitReferenceToPrimaryTable() {
final PersistenceUnitDescriptorAdapter pu = new PersistenceUnitDescriptorAdapter() {
@Override
public List<String> getManagedClassNames() {
return Arrays.asList(AnEntity.class.getName());
}
};
final Map settings = new HashMap();
settings.put(AvailableSettings.HBM2DDL_AUTO, "create-only");
EntityManagerFactory emf = null;
try {
Triggerable triggerable = logInspection.watchForLogMessages("Unrecognized " + AvailableSettings.HBM2DDL_AUTO + " value");
emf = Bootstrap.getEntityManagerFactoryBuilder(pu, settings).build();
emf.createEntityManager();
assertFalse(triggerable.wasTriggered());
} finally {
if (emf != null) {
emf.close();
}
}
}
use of org.hibernate.testing.orm.jpa.PersistenceUnitDescriptorAdapter in project hibernate-orm by hibernate.
the class JakartaSchemaToolingTests method buildSessionFactory.
private SessionFactoryImplementor buildSessionFactory(Object... settingPairs) {
final Properties settings = CollectionHelper.toProperties(settingPairs);
final PersistenceUnitDescriptorAdapter puDescriptor = new PersistenceUnitDescriptorAdapter() {
@Override
public Properties getProperties() {
return settings;
}
@Override
public List<String> getManagedClassNames() {
return Collections.singletonList(SimpleEntity.class.getName());
}
};
final EntityManagerFactoryBuilder emfBuilder = Bootstrap.getEntityManagerFactoryBuilder(puDescriptor, settings, (mergedSettings) -> mergedSettings.getConfigurationValues().clear());
return emfBuilder.build().unwrap(SessionFactoryImplementor.class);
}
Aggregations