List of usage examples for org.hibernate.cfg Configuration setProperties
public Configuration setProperties(Properties properties)
From source file:uk.ac.ebi.metabolights.repository.dao.hibernate.DDLTest.java
License:Apache License
@Before public void setUp() throws Exception { Configuration configuration = new Configuration(); // Get property file Properties hibernateProperties = new Properties(); hibernateProperties.load(DDLTest.class.getResourceAsStream("/hibernate.hidden.properties")); configuration.setProperties(hibernateProperties); configuration.setProperty("hibernate.hbm2ddl.auto", "create-drop"); HibernateUtil.initialize(configuration); }
From source file:uk.ac.ebi.metabolights.search.service.imp.es.ElasticSearchServiceTest.java
License:Apache License
@Before public void init() throws DAOException { String studiesFolderName = System.getenv("STUDIES_FOLDER"); Assert.assertNotNull("STUDIES_FOLDER: Studies folder variable NOT provided.", studiesFolderName); curatorToken = System.getenv("CURATOR_TOKEN"); STUDIES_FOLDER = studiesFolderName;// www . j a v a2s . c om ISATAB_CONFIG_FOLDER = System.getenv("ISATAB_CONFIG_FOLDER"); Assert.assertNotNull("ISATAB_CONFIG_FOLDER: ISA Configuration folder variable NOT provided.", ISATAB_CONFIG_FOLDER); // Configure database connection Configuration configuration = new Configuration(); // Get property file (an empty one is taking default hibernate.properties)!!! Properties hibernateProperties = new Properties(); configuration.setProperties(hibernateProperties); DAOFactory.initialize(ISATAB_CONFIG_FOLDER, STUDIES_FOLDER, configuration); // Get the studyDAO. studyDAO = DAOFactory.getInstance().getStudyDAO(); initDB(); }
From source file:us.opulo.p.hibernate.SessionProvider.java
License:Open Source License
private SessionFactory initializeSessionFactory(HibernateConfig config) { Configuration conf = new Configuration(); conf.setProperties(config.getProperties()); for (Class<? extends HEntity> entityClass : config.getClasses()) { conf.addAnnotatedClass(entityClass); }// ww w . jav a2 s . co m return conf.buildSessionFactory(); }