在Tomcat5.5.x环境下,调用Configuration().addCacheableFile来载入配置,建立Hibernate SessionFactory,成功地提高了载入速度。
推荐你只是在开发阶段采用这样的方式载入,最后的产品发布阶段你仍需使用经典的Hibernate.cfg.xml文件,通过Tomcat的 ServletContextListener API在应用程序部署的时候建立Hibernate SessionFactory,而不是在程序第一次调用Hiberante的时候。
全文阅读:http://www.javah.net/Hibernate/20070428/575.html