-
Jul 27th, 2011, 08:35 AM
#1
Memory Problems with two session factories
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).
I am using opensession in view filter
Code:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<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.CustomDial ect
</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">thre ad</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>
Code:
<bean id="archivalSessionFactory"
class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
<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.CustomDial ect
</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">thre ad</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>
Last edited by jforjava1981; Jul 27th, 2011 at 08:45 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules