Java 硬编码的hibernate.cfg.xml
如何在Hibernate中硬编码配置对象?这是我到目前为止所拥有的;我希望这能给你一个我想做的要点:Java 硬编码的hibernate.cfg.xml,java,xml,hibernate,persistence,Java,Xml,Hibernate,Persistence,如何在Hibernate中硬编码配置对象?这是我到目前为止所拥有的;我希望这能给你一个我想做的要点: Configuration config = new Configuration(); config.addAnnotatedClass(GenericMetadatable.class); config.addAnnotatedClass(SimpleMetadataValue.class); config.setProperty("connection.dri
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();
问题是:
config.addProperties(new Properties() {{}});
config.configure();
您不能有多个配置。您能正确解释您的问题吗?1您没有说明实际问题是什么。