use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class CmtSfStatefulBean method start.
@TransactionAttribute(TransactionAttributeType.NEVER)
public void start() {
try {
Configuration configuration = new Configuration();
configuration = configuration.configure("hibernate.cfg.xml");
configuration.addAnnotatedClass(WildFlyDdlEntity.class);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class ArrayTypeContributorTest method constructAndConfigureConfiguration.
@Override
protected Configuration constructAndConfigureConfiguration() {
Configuration configuration = super.constructAndConfigureConfiguration();
configuration.registerTypeContributor((typeContributions, serviceRegistry) -> {
typeContributions.contributeType(ArrayType.INSTANCE, new String[] { MyList.class.getName(), ArrayType.INSTANCE.getName() });
});
return configuration;
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class OrmXmlParseTest method parseNamedAttributeNode.
@Test
@TestForIssue(jiraKey = "HHH-9247")
public void parseNamedAttributeNode() {
final Configuration cfg = new Configuration();
cfg.addURL(ConfigHelper.findAsResource("org/hibernate/test/annotations/entityGraph/orm.xml"));
cfg.buildMappings();
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class FetchProfileTest method testFetchProfileConfigured.
@Test
public void testFetchProfileConfigured() {
Configuration config = new Configuration();
config.addAnnotatedClass(Customer.class);
config.addAnnotatedClass(Order.class);
config.addAnnotatedClass(SupportTickets.class);
config.addAnnotatedClass(Country.class);
SessionFactoryImplementor sessionImpl = (SessionFactoryImplementor) config.buildSessionFactory(serviceRegistry);
assertTrue("fetch profile not parsed properly", sessionImpl.containsFetchProfileDefinition("customer-with-orders"));
assertFalse("package info should not be parsed", sessionImpl.containsFetchProfileDefinition("package-profile-1"));
sessionImpl.close();
}
use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.
the class FetchProfileTest method testXmlOverride.
@Test
public void testXmlOverride() {
Configuration config = new Configuration();
config.addAnnotatedClass(Customer5.class);
config.addAnnotatedClass(Order.class);
config.addAnnotatedClass(Country.class);
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("org/hibernate/test/annotations/fetchprofile/mappings.hbm.xml");
config.addInputStream(is);
SessionFactoryImplementor sessionImpl = (SessionFactoryImplementor) config.buildSessionFactory(serviceRegistry);
assertTrue("fetch profile not parsed properly", sessionImpl.containsFetchProfileDefinition("orders-profile"));
sessionImpl.close();
// now the same with no xml
final MetadataSources metadataSources = new MetadataSources().addAnnotatedClass(Customer5.class).addAnnotatedClass(Order.class).addAnnotatedClass(Country.class);
try {
metadataSources.buildMetadata();
fail();
} catch (MappingException e) {
log.trace("success");
} finally {
ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
if (metaServiceRegistry instanceof BootstrapServiceRegistry) {
BootstrapServiceRegistryBuilder.destroy(metaServiceRegistry);
}
}
}
Aggregations