title: How do you translate Hibernate class mappings to a Spring application context?
body: <p>How do you configure the <a href="http://www.hibernate.org/">Hibernate</a> class mappings of class <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/orm/hibernate3/LocalSessionFactoryBean.html">org.springframework.orm.hibernate3.LocalSessionFactoryBean</a> in the <a href="http://www.springsource.org/">Spring</a> <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/context/ApplicationContext.html">application context</a>?  I want to move the <a href="http://docs.jboss.org/hibernate/stable/core/api/org/hibernate/SessionFactory.html">session factory</a> class mappings from the following <a href="http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html#configuration-xmlconfig"><code>hibernate.cfg.xml</code></a> to the corresponding Spring session factory bean so that I may eliminate <code>hibernate.cfg.xml</code>.</p>
  
  <p>File <code>hibernate.cfg.xml</code>:</p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;!DOCTYPE hibernate-configuration PUBLIC
      "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
      "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"&gt;
  &lt;hibernate-configuration&gt;
      &lt;session-factory&gt;
          &lt;!-- ... --&gt;
          &lt;mapping resource="Queries.hbm.xml" /&gt;
          &lt;mapping class="com.company.app.common.model.Account" /&gt;
          &lt;mapping class="com.company.app.common.model.AccountCategory" /&gt;
          &lt;mapping class="com.company.app.common.model.AssetType" /&gt;
          &lt;mapping class="com.company.app.common.model.Book" /&gt;
          &lt;mapping class="com.company.app.model.AssetTypeCategory" /&gt;
          &lt;!-- ... --&gt;
      &lt;/session-factory&gt;
  &lt;/hibernate-configuration&gt;
  </code></pre>
  
  <p>File <code>spring-application-context.xml</code>:</p>
  
  <pre><code>&lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"&gt;
      &lt;property name="configurationClass"&gt;
          &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt;
      &lt;/property&gt;
      &lt;property name="configLocation"&gt;
          &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;!-- Instead of the above, I want to use the following. Where and
      how do I define the class mappings so that I may eliminate
      hibernate.cfg.xml? --&gt;
      &lt;--
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="mappingResources"&gt;
          &lt;list&gt;
              &lt;value&gt;Queries.hbm.xml&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      --&gt;
  &lt;/bean&gt;
  </code></pre>