Can I have two databases related session-factory tags in a single hibernate.cfg.xml file?
-
29-09-2019 - |
Question
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 way to handle this ?
Solution
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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow