-->
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: Txn/Query/C3p0 Timeout does NOT work.. Need help! :(
PostPosted: Wed Dec 07, 2011 6:47 pm 
Newbie

Joined: Sat Jul 30, 2011 2:37 pm
Posts: 3
i been trouble shooting this hibernate/oracle10g issue all day.. I can't seem to get any of the timeouts to work. I wrote a test case just to test out the different ways of setting these timeouts, but none really seem to work for me.. The query would continue to run pass the timeout value that I set..

I'm using a DriverManagerDataSource here because I'm running this testcase in Eclipse, just to prove out the timeout concept. In production we are using a container managed datasource.

Code:
   private int txnTimeout = 10;
   private int queryTimeout = 10;

      try {
         Transaction txn = sessionFactory.getCurrentSession().getTransaction();
         txn.setTimeout(txnTimeout);  // I tried setting the timeout here..
         txn.begin();

         List<Object[]> results = sessionFactory.getCurrentSession().createSQLQuery("I have a query that takes very long to return here :)")
                        .setTimeout(queryTimeout) // I tried setting the timeout here..
                        .setCacheable(false)
                        .list();
      } finally {
         sessionFactory.getCurrentSession().close();
      }


Code:
   <!-- Hibernate's Session Factory -->
   <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      <property name="dataSource" ref="dataSource" />
      <property name="packagesToScan" value="com.xxx.xxx.xxx" />
      <property name="hibernateProperties">
         <value>
            hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
            hibernate.current_session_context_class=thread
            hibernate.id.new_generator_mappings=true
            hibernate.show_sql=false
            hibernate.format_sql=false
            hibernate.use_sql_comments=false
            hibernate.connection.release_mode=after_transaction
            hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider
            hibernate.c3p0.min_size=5
            hibernate.c3p0.max_size=20
            hibernate.c3p0.timeout=30 <!-- i tried setting the timeout here also -->
            hibernate.c3p0.max_statements=50
         </value>
      </property>

   <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
      <property name="url" value="xxxx" />
      <property name="username" value="xxxx" />
      <property name="password" value="xxxx" />
   </bean


Any help on this topic will really be appreciated! Thanks in advance


Top
 Profile  
 
 Post subject: Re: Txn/Query/C3p0 Timeout does NOT work.. Need help! :(
PostPosted: Fri Sep 05, 2014 3:25 pm 
Newbie

Joined: Wed Aug 24, 2011 5:19 pm
Posts: 4
query.setTimeout(queryTimeout) should work fine..which version of hibernate are you using?

queryTimeout in seconds


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.