Hi,

 

I couldn’t find any discussion on this topic so am posting this to the newsgroup …

 

I am running into a situation where I want to initialize a Hibernate Configuration object from a hibernate cfg file, but without any mappings (i.e without any <mapping> elements). Instead, I want to add the mappings programmatically. However, during initialization of the Configuration object, I get a parser error since the DTD for the hibernate config file requires at least one <mapping> element be specified under the <session-factory> element.

 

So, a configuration like this:

 

<hibernate-configuration>

            <session-factory>

                        <property name=”XYZ”>lkjsdlfkjsd</property>

                        …

                        <mapping resource=”com/mycompany/X.hbm.xml”/> ## THIS PORTION IS REQUIRED ###

            </session-factory>

</hibernate-configuration>

 

… will give an error if the <mapping> element is removed, based on the DTD.

 

My question is, why is this required? It defeats the purpose of being able to specify different portions of the configuration separately …

 

Also, is there any way to not have to specify this <mapping> element? I tried giving an empty <mapping> element and one with <mapping resource=””/> but both throw errors as well.

 

Any ideas will be greatly appreciated.

 

Thanks,

Safdar

Reply via email to