static EntityManagerFactory init() {
try {
Map<String, Object> props = new HashMap<>();
props.put("javax.persistence.jdbc.driver", "org.h2.Driver");
props.put("javax.persistence.jdbc.url", "jdbc:h2:mem:test"); // in-memory db
props.put("javax.persistence.schema-generation.database.action", "drop-and-create"); // create brand-new db schema in memory
props.put("hibernate.dialect", "org.hibernate.dialect.H2Dialect");
props.put("hibernate.show_sql", "false"); // Set this to true to debug any DB failures
props.put("hibernate.hbm2ddl.halt_on_error", Boolean.TRUE); // Cause test to fail in case of any errors during db creation
emf = Persistence.createEntityManagerFactory("osc-server", props);
return emf;
} catch (Throwable ex) {
System.out.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
InMemDB.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:osc-core
作者:
评论列表
文章目录