use of org.hibernate.cfg.Configuration in project wildfly by wildfly.
the class SFSBHibernate2LcacheStats method setupConfig.
@TransactionAttribute(TransactionAttributeType.NEVER)
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.getProperties().put(AvailableSettings.JTA_PLATFORM, JBossAppServerJtaPlatform.class);
configuration.getProperties().put(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
// set property to enable statistics
configuration.setProperty("hibernate.generate_statistics", "true");
// fetch the properties
Properties properties = new Properties();
configuration = configuration.configure("hibernate.cfg.xml");
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
// build the serviceregistry
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
ex.printStackTrace();
throw new ExceptionInInitializerError(ex);
}
//System.out.println("setupConfig: done");
}
use of org.hibernate.cfg.Configuration in project wildfly by wildfly.
the class SFSBHibernateSessionFactory method setupConfig.
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
configuration.setProperty("hibernate.listeners.envers.autoRegister", "false");
// fetch the properties
Properties properties = new Properties();
configuration = configuration.configure("hibernate.cfg.xml");
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
throw new RuntimeException("Could not setup config", ex);
}
}
use of org.hibernate.cfg.Configuration in project wildfly by wildfly.
the class SFSBHibernateEnversSessionFactory method setupConfig.
public void setupConfig() {
// static {
try {
// prepare the configuration
Configuration configuration = new Configuration().setProperty(AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS, "true");
configuration.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
configuration.setProperty(Environment.DATASOURCE, "java:jboss/datasources/ExampleDS");
// fetch the properties
Properties properties = new Properties();
configuration = configuration.configure("hibernate.cfg.xml");
properties.putAll(configuration.getProperties());
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
sessionFactory = configuration.buildSessionFactory();
} catch (Throwable ex) {
// Make sure you log the exception, as it might be swallowed
throw new RuntimeException("Could not setup config", ex);
}
}
use of org.hibernate.cfg.Configuration in project API by ca-cwds.
the class ClientDaoIT method beforeClass.
@SuppressWarnings("javadoc")
@BeforeClass
public static void beforeClass() {
sessionFactory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
clientDao = new ClientDao(sessionFactory);
}
use of org.hibernate.cfg.Configuration in project API by ca-cwds.
the class ClientUcDaoIT method setup.
/**
*
*/
@Override
@Before
public void setup() {
sessionFactory = new Configuration().configure().buildSessionFactory();
sessionFactory.getCurrentSession().beginTransaction();
clientUcDao = new ClientUcDao(sessionFactory);
}
Aggregations