您可以以编程方式加载hibernate配置文件。
SessionFactory sf = new Configuration().configure("somename.cfg.xml").buildSessionFactory();那将允许您创建两个SessionFactory对象。但是,我假设您想为您的应用程序和模块使用相同的SessionFactory。
您可以将两个hibernateXML文件都加载到单个DOM对象中(将模块的“ session-factory”标记子代与应用程序的子代结合起来),然后使用以下代码:
import org.hibernate.cfg.Configuration;// ...SessionFactory sf = new Configuration().configure(yourDOMObject).buildSessionFactory();
编辑:没有打印session-factory,因为它具有大于和小于字符。



