开发者

Can I have two databases related session-factory tags in a single hibernate.cfg.xml file?

开发者 https://www.devze.com 2023-01-24 16:40 出处:网络
I have two different databases where I need to connect and update the tables dynamically. But it looks like I cannot keep two sessions related information in configuration file.

I have two different databases where I need to connect and update the tables dynamically. But it looks like I cannot keep two sessions related information in configuration file. Is there any w开发者_如何学JAVAay to handle this ?


Well, as you noticed, the root element of Hibernate's XML configuration file must declare one and only one <session-factory> element as per the DTD:

<!ELEMENT hibernate-configuration (session-factory,security?)>

So if you want to configure multiple session factories, either:

  • Use a programmatic configuration approach
  • Use several hibernate.cfg.xml

References

  • Hibernate Core Reference Guide
    • 3.1. Programmatic configuration
    • 3.7. XML configuration file
0

精彩评论

暂无评论...
验证码 换一张
取 消