Consider the following:
<!-- Hibernate SessionFactory -->
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<value>petclinic.hbm.xml</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
</props>
</property>
</bean>
Don't we also have to be able (if we want) to specify Hibernate "class-cache" and "collection-cache" elements (for any number of classes) here in this session factory bean definition... otherwise we'd still need an external Hibernate configuration file, e.g., "hibernate.config.xml"?
This brings me to my next question. Above, we declare a session factory as a Spring bean, named "sessionFactory". If I want/need to reference a separate Hibernate configuration file, e.g., ...
(Spring XML App Context):
<!-- Hibernate SessionFactory -->
<bean
id="sessionFactory"
class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
hibernate.config.xml:
<hibernate-configuration>
<session-factory name="hibernate/SomeSessionFactory">
...
</session-factory>
</hibernate-configuration>
... then, how can I end up with the one session factory ("sessionFactory", reified as a Spring bean) that I actually want, when, by using hibernate.cfg.xml, I have to declare another, JNDI-bound, session factory?
Thanks for any help that you can offer for these questions.


Reply With Quote