Results 1 to 5 of 5

Thread: Slow transactions with Spring+Hibernate3+Oracle

  1. #1
    Join Date
    Jul 2005
    Posts
    2

    Default Slow transactions with Spring+Hibernate3+Oracle

    Hi,
    I have a sample application with Spring1.2.1, Hibernate 3.0.5 and Oracle 8.1.6 and I've found that it takes about 11 seconds!! to make an insert into an Oracle Database.
    I have traced and found that the calls to TransactionAspectSupport.createTransactionIfNecess ary(), and TransactionAspectSupport.doCommitTransactionAfterR eturning(), eat up most of the time.

    The same configuration and code takes up millis when inserting into a HSQL DataBase.

    I'm running jdk 1.5.0_03.

    Any help will be appreciated.

    Regards.

    Rodolfo Martín.

    My application-context

    Code:
    <beans>
        <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                <list>
                    <value>db.properties</value>
                </list>
            </property>
        </bean>
    
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName"><value>$&#123;jdbc.driverClassName&#125;</value></property>
            <property name="url"><value>$&#123;jdbc.url&#125;</value></property>
            <property name="username"><value>$&#123;jdbc.username&#125;</value></property>
            <property name="password"><value>$&#123;jdbc.password&#125;</value></property>
        </bean>
        <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
            <constructor-arg><ref local="dataSource"/></constructor-arg>
        </bean>
    
        <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
            <property name="dataSource"><ref local="dataSource"/></property>
            <property name="mappingResources">
                <value>com/mycompany/myapp/hibernate/mapping.hbm.xml</value>
            </property>
            <property name="hibernateProperties">
                <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                    <prop key="hibernate.show_sql">true</prop>
                </props>
            </property>
            <property name="eventListeners">
                <map>
                    <entry key="merge">
                        <bean class="org.springframework.orm.hibernate3.support.IdTransferringMergeEventListener"/>
                    </entry>
                </map>
            </property>
        </bean>
    
        <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
    
        <bean id="propertyManagerTarget" class="com.mycompany.myapp.hibernate.TestDao">
            <property name="sessionFactory"><ref local="sessionFactory"/></property>
        </bean>
        
        <bean id="propertyManager" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
            <property name="transactionManager"><ref local="transactionManager"/></property>
            <property name="target"><ref local="propertyManagerTarget"/></property>
            <property name="transactionAttributes">
                <props>
                    <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="load*">PROPAGATION_REQUIRED,readOnly</prop>
                    <prop key="store*">PROPAGATION_REQUIRED</prop>
                </props>
            </property>
        </bean>
    </beans>
    My Dao implementation:
    Code:
    public class TestDao extends HibernateDaoSupport implements Test&#123;
            
        public <T extends TestData> void store&#40;T testData&#41; throws DataAccessException &#123;
            getHibernateTemplate&#40;&#41;.merge&#40;testData&#41;;
        &#125;
    &#125;

  2. #2
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    The places that seem to take most of the time are places where connections are made and disconnected. Can it be that it simply takes a long time to create an Oracle connection? What happens if you create a pooled datasource and execute the method several times?

  3. #3
    Join Date
    Jul 2005
    Posts
    1

  4. #4
    Join Date
    Jul 2005
    Posts
    2

    Default

    Thank you very much for your help: the problem is solved!

    dejanp is right: When using DriverManagerDataSource the connection is open an dropped on every operation. Using a pooled datasource solves the problem.

    On the other hand the link nds1424 provides explains why it is taken so much time to open a connection with Oracle. It will be useful for me to avoid waiting so much when opening the connections.

    Best Regards.

    Rodolfo Martín

  5. #5
    Join Date
    Nov 2004
    Posts
    159

    Default

    Could you please tell me how to use pooled datasource?

    Thanks for your help in advance!

Similar Threads

  1. Oracle, Spring - JDBC exception
    By jakim8915 in forum Data
    Replies: 5
    Last Post: Aug 7th, 2006, 09:20 AM
  2. Replies: 10
    Last Post: Sep 28th, 2005, 07:01 AM
  3. Replies: 2
    Last Post: May 26th, 2005, 02:30 AM
  4. Replies: 1
    Last Post: Mar 14th, 2005, 04:59 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •