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!