-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Memory Probelms with two session factories
PostPosted: Wed Jul 27, 2011 9:25 am 
Newbie

Joined: Tue Jul 27, 2010 5:19 am
Posts: 4
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]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.