我配置我的SessionFactory编程:使用Hibernate的编程配置,开始hibernate.hbm2ddl.auto
private static SessionFactory buildSessionFactory() {
// Create the SessionFactory from hibernate.cfg.xml
Configuration configuration = new Configuration();
configuration.configure();
configuration.setProperty("hibernate.connection.url", myUrl);
configuration.setProperty("hibernate.connection.username", myUser);
configuration.setProperty("hibernate.connection.password", myPass);
serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
return configuration.buildSessionFactory(serviceRegistry);
}
但问题是,这些属性是使用休眠操作时才会加载,从道。
因此,当我的应用程序启动时,则hibernate.hbm2ddl.auto似乎并没有工作。我可以以某种方式迫使hibernate.hbm2ddl.auto在我的程序或任何其他解决方案中启动?
推荐或其他选项,想法?
'配置配置=新配置();'应该加载我现有的hibernate.cfg.xml,我有和有行:' create ' –
Jaanus