Hi,
I am creating two hibernate session factories using Spring. I get memory heap space when i start my application. I know its expensive to create a session factory but i need to create two as they point to two different datasources. Can i somehow load these hbms only once.I think thats what creating a problem(loading all hbms twice).
Code:
[color=#800000]<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/cmt/acq/db</value>
<value>classpath:/com/cmt/auth/db</value>
<value>classpath:/com/cmt/pcm/db</value>
<value>classpath:/com/cmt/vendor/db</value>
<value>classpath:/com/cmt/db</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">com.cmt.dialect.CustomDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.autocommit">false</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>[/color]
Code:
[color=#FF0000]<bean id="archivalSessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="archivalDataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/cmt/acq/db</value>
<value>classpath:/com/cmt/auth/db</value>
<value>classpath:/com/cmt/pcm/db</value>
<value>classpath:/com/cmt/vendor/db</value>
<value>classpath:/com/cmt/db</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">com.cmt.dialect.CustomDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
<prop key="hibernate.max_fetch_depth">2</prop>
<prop key="hibernate.autocommit">false</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>[/color]