Hibernate version: 2.1.7
Perhaps I'm reading the documentation incorrectly, but I'm having trouble configuring my application to have more than one SessionFactory. It seems as though there is a contradiction between what's in the documentation and what's in the DTD.
In the DTD (
http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd), the comment at the top of the file says "... a number of SessionFactory instances to be listed in JNDI ...". But the DTD describes the hibernate-configuration element as
Code:
<!ELEMENT hibernate-configuration (session-factory)>
Which I believe means that only one element of session-factory is expected.
How can you configure multiple session factories in the hibernate.cfg.xml file?
FYI - I've tried code like:
Code:
<hibernate-configuration>
<session-factory name="java:comp/env/hibernate/SFOne">
<!-- direct JDBC connection properties -->
<!-- mapping files -->
<mapping resource="com/fsb/DocumentType.hbm.xml" />
<mapping resource="com/fsb/Document.hbm.xml" />
</session-factory>
<session-factory name="java:comp/env/hibernate/SFTwo">
<!-- direct JDBC connection properties -->
<!-- mapping files -->
<mapping resource="com/fsb/Code.hbm.xml" />
</session-factory>
</hibernate-configuration>
but get the following exception when running my JUnit tests:
Full stack trace of any exception that occurs:
Error parsing XML: /hibernate.cfg.xml(45) The content of element type "hibernate-configuration" must match "(session-factory)".
I'm pretty sure I can see how it would be done programmatically, but I'd be interested in knowing if there is a way to do it using something built into the configuration file.
Interestingly enough, Gavin, you said you were thinking about it back in 2002. (
http://www.mail-archive.com/hibernate-devel@lists.sourceforge.net/msg00834.html) Did you get it done?
Joe