Search in sources :

Example 81 with Configuration

use of org.hibernate.cfg.Configuration in project scheduling by ow2-proactive.

the class NodeHistoryTest method initDB.

@BeforeClass
public static void initDB() throws Exception {
    PAResourceManagerProperties.RM_ALIVE_EVENT_FREQUENCY.updateProperty("100");
    Configuration config = new Configuration().configure("/functionaltests/config/hibernate-unit.cfg.xml");
    dbManager = new RMDBManager(config, true, true);
}
Also used : RMDBManager(org.ow2.proactive.resourcemanager.db.RMDBManager) Configuration(org.hibernate.cfg.Configuration) BeforeClass(org.junit.BeforeClass)

Example 82 with Configuration

use of org.hibernate.cfg.Configuration in project scheduling by ow2-proactive.

the class SchedulerDBManager method createUsingProperties.

public static SchedulerDBManager createUsingProperties() {
    if (System.getProperty(JAVA_PROPERTYNAME_NODB) != null) {
        return createInMemorySchedulerDBManager();
    } else {
        File configFile = new File(PASchedulerProperties.getAbsolutePath(PASchedulerProperties.SCHEDULER_DB_HIBERNATE_CONFIG.getValueAsString()));
        Map<String, String> propertiesToReplace = new HashMap<>(2, 1f);
        propertiesToReplace.put("${proactive.home}", CentralPAPropertyRepository.PA_HOME.getValue());
        propertiesToReplace.put("${pa.scheduler.home}", PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
        Configuration configuration = createConfiguration(configFile, propertiesToReplace);
        boolean drop = PASchedulerProperties.SCHEDULER_DB_HIBERNATE_DROPDB.getValueAsBoolean();
        if (logger.isInfoEnabled()) {
            logger.info("Starting Scheduler DB Manager " + "with drop DB = " + drop + " and configuration file = " + configFile.getAbsolutePath());
        }
        return new SchedulerDBManager(configuration, drop);
    }
}
Also used : Configuration(org.hibernate.cfg.Configuration) HashMap(java.util.HashMap) File(java.io.File)

Example 83 with Configuration

use of org.hibernate.cfg.Configuration in project scheduling by ow2-proactive.

the class SchedulerDBManager method createInMemorySchedulerDBManager.

public static SchedulerDBManager createInMemorySchedulerDBManager() {
    Configuration config = new Configuration();
    config.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbc.JDBCDriver");
    config.setProperty("hibernate.connection.url", "jdbc:hsqldb:mem:" + System.currentTimeMillis() + ";hsqldb.tx=mvcc");
    config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
    return new SchedulerDBManager(config, true);
}
Also used : Configuration(org.hibernate.cfg.Configuration)

Example 84 with Configuration

use of org.hibernate.cfg.Configuration in project scheduling by ow2-proactive.

the class BaseSchedulerDBTest method initTest.

@Before
public void initTest() throws Exception {
    if (System.getProperty("pa.scheduler.home") == null) {
        PASchedulerProperties.SCHEDULER_HOME.updateProperty(ClasspathUtils.findSchedulerHome());
    }
    System.out.println("Scheduler home : " + PASchedulerProperties.SCHEDULER_HOME.getValueAsString());
    PASchedulerProperties.TASK_FORK.updateProperty("true");
    CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
    if (inMemory) {
        dbManager = SchedulerDBManager.createInMemorySchedulerDBManager();
    } else {
        Configuration config = new Configuration().configure(new File(this.getClass().getResource("/functionaltests/config/hibernate-unit.cfg.xml").toURI()));
        dbManager = new SchedulerDBManager(config, true);
    }
}
Also used : Configuration(org.hibernate.cfg.Configuration) SchedulerDBManager(org.ow2.proactive.scheduler.core.db.SchedulerDBManager) File(java.io.File) Before(org.junit.Before)

Example 85 with Configuration

use of org.hibernate.cfg.Configuration in project hibernate-orm by hibernate.

the class BmtSfStatefulBean method start.

public void start() {
    Configuration configuration = new Configuration();
    configuration = configuration.configure("hibernate.cfg.xml");
    configuration.addAnnotatedClass(WildFlyDdlEntity.class);
    // creating the SF should run schema creation
    sessionFactory = configuration.buildSessionFactory();
}
Also used : Configuration(org.hibernate.cfg.Configuration)

Aggregations

Configuration (org.hibernate.cfg.Configuration)190 Test (org.junit.Test)66 Session (org.hibernate.Session)37 SessionFactory (org.hibernate.SessionFactory)35 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)27 Before (org.junit.Before)20 BeforeClass (org.junit.BeforeClass)20 File (java.io.File)18 ServiceRegistry (org.hibernate.service.ServiceRegistry)14 Properties (java.util.Properties)13 StandardServiceRegistryBuilder (org.hibernate.boot.registry.StandardServiceRegistryBuilder)9 HibernateException (org.hibernate.HibernateException)8 EncapsulatedCompositeIdResultSetProcessorTest (org.hibernate.test.loadplans.process.EncapsulatedCompositeIdResultSetProcessorTest)8 MappingException (org.hibernate.MappingException)7 Transaction (org.hibernate.Transaction)7 URL (java.net.URL)6 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 TestForIssue (org.hibernate.testing.TestForIssue)6 EntityTuplizer (org.hibernate.tuple.entity.EntityTuplizer)6 BigDecimal (java.math.BigDecimal)5