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