title: Spring and hibernate.cfg.xml
body: <p>How do I get Spring to load Hibernate's properties from <code>hibernate.cfg.xml</code>?</p>
  
  <p>We're using Spring and JPA (with Hibernate as the implementation). Spring's <code>applicationContext.xml</code> specifies the JPA dialect and Hibernate properties:</p>
  
  <pre><code>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"&gt;
      &lt;property name="jpaDialect"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLInnoDBDialect&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In this configuration, Spring is reading all the Hibernate properties via applicationContext.xml . When I create a <code>hibernate.cfg.xml</code> (located at the root of my classpath, the same level as META-INF), Hibernate doesn't read it at all (it's completely ignored).</p>
  
  <p>What I'm trying to do is configure Hibernate second level cache by inserting the cache properties in <code>hibernate.cfg.xml</code>:</p>
  
  <pre><code>&lt;cache 
      usage="transactional|read-write|nonstrict-read-write|read-only"
      region="RegionName"
      include="all|non-lazy"
  /&gt;
  </code></pre>