Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel

Anchor
Session Factory configuration for of hibernate mappings for CSF version 2
Session Factory configuration for of hibernate mappings for CSF version 2

Session Factory configuration

for

of hibernate mappings for CSF version 2

Locate your project's sessionFactory bean and add the mappingLocations property as shown below:

Code Block
    <bean id="sessionFactory" parent="abstractSessionFactory" >
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.jdbc.use_scrollable_resultset">true</prop>
                <prop key="hibernate.jdbc.batch_size">20</prop>
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.cache.use_structured_entries">true</prop>
                <prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
                <prop key="edu.mit.common.domain.student.hibernate.cache.use_query_cache">true</prop>
            </props>
        </property>
        <property name="mappingLocations">
            <list>
                <value>classpath*:edu/mit/csf/example/academic/hibernate/*.hbm.xml</value>
                <value>classpath*:edu/mit/csf/example/student/hibernate/*.hbm.xml</value>
            </list>
        </property> 
    </bean>
  1. Each project should only have 1 sessionFactory bean defined.
    • For WAR file projects:  The sessionFactory bean should be defined in the project's /src/main/resouces/applicationContext-<projectName>-config.xml file.
    • For JAR file projects:  The sessionFactory bean should be defined in the project's src/test/resources/applicationContext-csf-<projectName>-config-test.xml file.
  2. Hibernate mappings contained in the CSF-COMMON-LEGACY jar file are automatically added to your project via the CSF abstractSessionFactory bean.