我如何在Hibernate中对配置对象进行硬编码?这是我到目前为止所拥有的;我希望这能给你一个我想要做的事情的要点:
Configuration config = new Configuration();
config.addAnnotatedClass(GenericMetadatable.class);
config.addAnnotatedClass(SimpleMetadataValue.class);
config.setProperty("connection.driver_class", "org.h2.Driver")
.setProperty("connection.url", "jdbc:h2:~/test")
.setProperty("connection.username", "sa")
.setProperty("connection.password", "")
.setProperty("hibernate.default_schema", "TESTSCHEMA2")
.setProperty("connection.pool_size", "2")
.setProperty("dialect", "org.hibernate.dialect.H2Dialect")
.setProperty("current_session_context_class", "thread")
.setProperty("cache.provider_class", "net.sf.ehcache.hibernate.EhCacheProvider")
.setProperty("show_sql", "true");
config.addProperties(new Properties() {{}});
config.configure();
答案 0 :(得分:0)
问题在于:
config.addProperties(new Properties() {{}});
config.configure();
您无法进行多项配置。