Results 1 to 3 of 3

Thread: Transaction timeout doesn't work

Hybrid View

  1. #1
    Join Date
    Sep 2008
    Posts
    17

    Default Transaction timeout doesn't work

    As title say I have problem with transaction timeout attribute because it doesn't rollback transaction after specific time and query is still running.

    I'm using Spring 2.5.6, Hibernate 3.3.2, Wicket 1.4.5 on Weblogic 10.3 and Informix 10.

    Here's my code and configuration:

    Code:
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
    		<property name="configLocation"
    			value="classpath:hibernate.cfg.xml">
    		</property>
    	</bean>
    
    	<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    
    	<tx:annotation-driven transaction-manager="txManager"/>
    
    	<bean id="myWeBApp" class="com.web.MyWebApplication">
        	<property name="tlogDAO" ref="tlogDAO"/>
    	</bean>
    
    	<bean id="tlogDAO" class="com.dao.TlogDAOImpl">
    		<property name="sessionFactory" ref="sessionFactory" />
    	</bean>
    Code:
    public class TlogDAOImpl implements TlogDAO {
    
    	private HibernateTemplate hibernateTemplate;
    
    	public void setSessionFactory(SessionFactory sessionFactory) {
    		this.hibernateTemplate = new HibernateTemplate(sessionFactory);
    	}
    
    	@SuppressWarnings("unchecked")
    	@Override
    	@Transactional(readOnly=true, timeout=30)
    	public List<Tlog> findAll(Tlog instance) {
    		return hibernateTemplate.findByExample(instance);
    	}
    
    }
    But if I change findAll method to this form I will get what I expect:
    Code:
    	public List<Tlog> findAll(Tlog instance) {
    		try {
    			Thread.sleep(30000);
    		} catch (InterruptedException e) {
    			e.printStackTrace();
    		}
    		return hibernateTemplate.findByExample(instance);
    	}
    Error:
    Code:
    org.hibernate.TransactionException: transaction timeout expired
         at org.hibernate.jdbc.AbstractBatcher.setTimeout(AbstractBatcher.java:552)
         at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:538)
    Although transaction is expired on my console sql is shown but I am quite sure that query is not executed.
    So the quesion is: why primary version doesn't work?

    Thanks for all responses and suggestions.

    Best Regards,
    Luke
    Last edited by lukep1984; Jan 29th, 2010 at 02:20 AM.

  2. #2
    Join Date
    Sep 2008
    Posts
    17

    Default

    Come on guys. Someone had to have similar problem. Does anybody use the timeout attribute? Does I have to set sth in hibernate configuration to able to rollback transaction?
    I changed transaction manager to JtaTranasactionManager but effect is infortunately the same.
    Why transaction is not able to interrupt hibernate query after timeout limit?

    Thanks, for all responses.
    Last edited by lukep1984; Feb 19th, 2010 at 06:32 AM.

  3. #3
    Join Date
    Nov 2007
    Posts
    17

    Default

    I am also facing the same problem; and this causes hung threads on my server. Any advice would be great!

Posting Permissions

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