如何在Tapestry5中使用自定义hibernate.cfg.xml文件路径

如何在Tapestry5中使用自定义hibernate.cfg.xml文件路径,hibernate,tapestry,Hibernate,Tapestry,如何在tapestry应用程序中更改hibernate配置文件hibernate.cfg.xml的名称或路径?在类AppModule中,有两种方法需要更改或创建: contributeApplicationDefaults,以禁用默认配置 contributeHibernateSessionSource提供您自己的服务 公共静态void contributeApplicationDefaults( 映射(配置){ //禁用对hibernate.configure()的调用以手动调用它 add(H

如何在tapestry应用程序中更改hibernate配置文件
hibernate.cfg.xml
的名称或路径?

在类
AppModule
中,有两种方法需要更改或创建:

  • contributeApplicationDefaults
    ,以禁用默认配置
  • contributeHibernateSessionSource
    提供您自己的服务
  • 公共静态void contributeApplicationDefaults(
    映射(配置){
    //禁用对hibernate.configure()的调用以手动调用它
    add(HibernateSymbols.DEFAULT_配置,“false”);
    }
    
    public void contributeHibernateSessionSource(
    OrderedConfiguration(配置程序){
    add(“hibernate会话源”,新的HibernateConfiguler(){
    公共void配置(org.hibernate.cfg.Configuration){
    configure(“my hibernate.cfg.xml”);
    }
    });
    }
    
    id
    hibernate会话源代码
    是任意的,似乎任何东西都可以工作。在这方面,建议选择一个独特的。在Tapestry 5.3.6中测试