-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate & Spring performance problem
PostPosted: Mon Jul 13, 2009 12:02 pm 
Newbie

Joined: Sun Oct 12, 2008 12:18 pm
Posts: 3
Hello!

I have application which is using Hibernate 3.2.5 and Spring 2.5 to connect to DB2 9.5 database.
Hibernate configuration is described in my Spring configuration file, so i am using Spring to get Hibernate Session Factory.
All transactions are managed declaratively through Spring AOP API (not through AspectJ annotations, all configuration is in XML file).

My application has a performance problem: beginning a Hibernate transaction takes a lot of time:

Code:
16:39:52,906 DEBUG HibernateTransactionManager:371 - Creating new transaction with name [***]: PROPAGATION_REQUIRED,ISOLATION_READ_COMMITTED,timeout_60,-Exception.class
16:39:53,156 DEBUG HibernateTransactionManager:496 - Opened new Session [org.hibernate.impl.SessionImpl@1eb5de5] for Hibernate transaction
16:39:53,171 DEBUG HibernateTransactionManager:507 - Preparing JDBC Connection of Hibernate Session [org.hibernate.impl.SessionImpl@1eb5de5]
16:39:53,203 DEBUG ConnectionManager:421 - opening JDBC connection
16:39:55,250 DEBUG DataSourceUtils:170 - Changing isolation level of JDBC Connection [com.ibm.db2.jcc.uw.UWConnection@1449aa1] to 2
16:39:55,281 DEBUG JDBCTransaction:54 - begin
16:39:55,281 DEBUG JDBCTransaction:59 - current autocommit status: true
16:39:55,281 DEBUG JDBCTransaction:62 - disabling autocommit
16:39:55,343 DEBUG HibernateTransactionManager:572 - Exposing Hibernate transaction as JDBC transaction [com.ibm.db2.jcc.uw.UWConnection@1449aa1]


As you can see from the log file, just opening JDBC connection to begin Hibernate transaction takes more than two seconds!

Part of my Spring application context is described below:

Code:

<bean id="dataSource" class="com.ibm.db2.jcc.DB2SimpleDataSource">
       <property name="password" value="password"/>
       <property name="user" value="user"/>
       <property name="databaseName" value="dbname"/>
   </bean>

   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
       <property name="dataSource" ref="dataSource"/>

       <property name="packagesToScan">
           <list>
              ***
           </list>
       </property>

       <property name="hibernateProperties">
           <props>
               <prop key="hibernate.dialect">org.hibernate.dialect.DB2Dialect</prop>
               <prop key="hibernate.hbm2ddl.auto">update</prop>
               <prop key="hibernate.max_fetch_depth">0</prop>
               <prop key="hibernate.cache.use_second_level_cache">false</prop>
           </props>
       </property>
   </bean>

   <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
       <property name="sessionFactory" ref="sessionFactory"/>
       <property name="dataSource" ref="dataSource"/>
   </bean>

   <bean id="hibernateDaoSupport" abstract="true"
        class="org.springframework.orm.hibernate3.support.HibernateDaoSupport">
        <property name="sessionFactory" ref="sessionFactory"/>
   </bean>


Does anybody know, is there any way to make Hibernate to work faster? Maybe i must add something to Spring configuration file?

Any help is greatly appreciated. Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Hibernate & Spring performance problem
PostPosted: Tue Jul 14, 2009 8:52 am 
Newbie

Joined: Sun Oct 12, 2008 12:18 pm
Posts: 3
Thanks everybody, the problem is solved.

If somebody faces the same issue, stop using com.ibm.db2.jcc.DB2SimpleDataSource, because it doesn't support conection pooling. Use C3P0 instead to keep a pool of active JDBC connections, which can be used by Hibernate to begin transactions.


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

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.