Techie:Techie Main/Java/Hibernate/Hibernate XML Config File
Hibernate will load config from a file called hibernate.cfg.xml on the classpath. It also possible to tell hibernate to use other files.
Although the hibernate connection properties can specified in the XML config file, it is better to configure these in the hibernate.properties file (follow link for reasoning). With this in mind we just use this file to include all the mapping files for our application.
Example hibernate.cfg.xml file
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <mapping resource="com/example/model/Player.hbm.xml" /> <mapping resource="com/example/model/Club.hbm.xml" /> </session-factory> </hibernate-configuration>