@Override public HbDataStore get() { final long COUNTER = System.currentTimeMillis(); final Properties props = new Properties(); props.setProperty(Environment.DRIVER, "org.hsqldb.jdbcDriver"); props.setProperty(Environment.USER, "SA"); props.setProperty(Environment.URL, "jdbc:hsqldb:mem:test" + COUNTER); props.setProperty(Environment.PASS, ""); props.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect"); props.setProperty(Environment.CURRENT_SESSION_CONTEXT_CLASS, "managed"); props.setProperty("teneo.mapping.disable_econtainer", "true"); props.setProperty("teneo.mapping.default_varchar_length", "60"); final HbDataStore hbds = HbHelper.INSTANCE.createRegisterDataStore("data-store-test" + COUNTER); hbds.setProperties(props); hbds.setEPackages(PersistenceModule.EPACKAGES); hbds.initialize(); System.err.println(" --> returngin data store : " + hbds); System.err.println(" " + hbds.getProperties().get(Environment.URL)); // Thread.dumpStack(); return hbds; }
private static Configuration generateTeneoHibernateConfig(DatabaseSetupData data) { // for teneo, we need to intialize the datastore in order ot properly // init the configuration. So we set an invalid db so init will fail, // but then we can use the config to generate schema... HbDataStore tempDataStore = HbHelper.INSTANCE.createRegisterDataStore("fakedatastore"); String savedDbName = data.getDatabaseName(); data.setDatabaseName("generateschema" + data.hashCode()); String savedUserName = data.getUserName(); data.setUserName(data.hashCode() + "generateschema"); try { tempDataStore.setProperties(data.getOptions()); tempDataStore.setEPackages(EPACKAGES); tempDataStore.initialize(); } catch (Throwable t) { System.out.println("Caught expected error: " + t.getMessage()); } data.setUserName(savedUserName); data.setDatabaseName(savedDbName); Configuration configuration = tempDataStore.getHibernateConfiguration(); return configuration; }
private void initializeDataStore() { hbds = HbHelper.INSTANCE.createRegisterDataStore(data.getDatabaseName()); hbds.setProperties(data.getOptions()); hbds.setEPackages(EPACKAGES); hbds.initialize(); }