How can I change the name or path of the hibernate configuration file hibernate.cfg.xml
in a tapestry application?
質問する
776 次
1 に答える
5
In the class AppModule
there are two methods that need to be changed or created:
contributeApplicationDefaults
, to disable the default configurationcontributeHibernateSessionSource
to provide your own.
public static void contributeApplicationDefaults(
MappedConfiguration<String, Object> configuration) {
// Disable call to hibernate.configure() to call it manually
configuration.add(HibernateSymbols.DEFAULT_CONFIGURATION, "false");
}
public void contributeHibernateSessionSource(
OrderedConfiguration<HibernateConfigurer> configurer) {
configurer.add("hibernate-session-source", new HibernateConfigurer() {
public void configure(org.hibernate.cfg.Configuration configuration) {
configuration.configure("my-hibernate.cfg.xml");
}
});
}
The id hibernate-session-source
is arbitrary, anything seems to work. In this discussion it's suggested to choose a unique one. Tested in Tapestry 5.3.6
于 2012-10-30T14:23:56.080 に答える