Buggy code:
public void setAutodetectDataSource ( boolean autodetectDataSource ) { } public void setPrepareConnection ( boolean prepareConnection ) { } public void setHibernateManagedSession ( boolean hibernateManagedSession ) { } public void setEntityInterceptorBeanName ( String entityInterceptorBeanName ) { } public void setEntityInterceptor ( Interceptor entityInterceptor ) { } public Interceptor getEntityInterceptor ( ) throws IllegalStateException , BeansException { } @ Override public void setBeanFactory ( BeanFactory beanFactory ) { } @ Override public void afterPropertiesSet ( ) { } @ Override public Object getResourceFactory ( ) { } @ Override protected Object doGetTransaction ( ) { } @ Override protected boolean isExistingTransaction ( Object transaction ) { } @ Override protected void doBegin ( Object transaction , TransactionDefinition definition ) { HibernateTransactionManager . HibernateTransactionObject txObject = ( ( HibernateTransactionManager . HibernateTransactionObject ) ( transaction ) ) ; if ( ( txObject . hasConnectionHolder ( ) ) && ( ! ( txObject . getConnectionHolder ( ) . isSynchronizedWithTransaction ( ) ) ) ) { throw new IllegalTransactionStateException ( ( "Pre-bound<seq2seq4repair_space>JDBC<seq2seq4repair_space>Connection<seq2seq4repair_space>found!<seq2seq4repair_space>HibernateTransactionManager<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>support<seq2seq4repair_space>" + ( ( "running<seq2seq4repair_space>within<seq2seq4repair_space>DataSourceTransactionManager<seq2seq4repair_space>if<seq2seq4repair_space>told<seq2seq4repair_space>to<seq2seq4repair_space>manage<seq2seq4repair_space>the<seq2seq4repair_space>DataSource<seq2seq4repair_space>itself.<seq2seq4repair_space>" + "It<seq2seq4repair_space>is<seq2seq4repair_space>recommended<seq2seq4repair_space>to<seq2seq4repair_space>use<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>HibernateTransactionManager<seq2seq4repair_space>for<seq2seq4repair_space>all<seq2seq4repair_space>transactions<seq2seq4repair_space>" ) + "on<seq2seq4repair_space>a<seq2seq4repair_space>single<seq2seq4repair_space>DataSource,<seq2seq4repair_space>no<seq2seq4repair_space>matter<seq2seq4repair_space>whether<seq2seq4repair_space>Hibernate<seq2seq4repair_space>or<seq2seq4repair_space>JDBC<seq2seq4repair_space>access." ) ) ) ; } Session session = null ; try { if ( ( ( txObject . getSessionHolder ( ) ) == null ) || ( txObject . getSessionHolder ( ) . isSynchronizedWithTransaction ( ) ) ) { Interceptor entityInterceptor = getEntityInterceptor ( ) ; Session newSession = ( entityInterceptor != null ) ? getSessionFactory ( ) . withOptions ( ) . interceptor ( entityInterceptor ) . openSession ( ) : getSessionFactory ( ) . openSession ( ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( ( "Opened<seq2seq4repair_space>new<seq2seq4repair_space>Session<seq2seq4repair_space>[" + newSession ) + "]<seq2seq4repair_space>for<seq2seq4repair_space>Hibernate<seq2seq4repair_space>transaction" ) ) ; } txObject . setSession ( newSession ) ; } session = txObject . getSessionHolder ( ) . getSession ( ) ; if ( ( this . prepareConnection ) && ( isSameConnectionForEntireSession ( session ) ) ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( ( "Preparing<seq2seq4repair_space>JDBC<seq2seq4repair_space>Connection<seq2seq4repair_space>of<seq2seq4repair_space>Hibernate<seq2seq4repair_space>Session<seq2seq4repair_space>[" + session ) + "]" ) ) ; } Connection con = ( ( org . hibernate . engine . spi . SessionImplementor ) ( session ) ) . connection ( ) ; Integer previousIsolationLevel = DataSourceUtils . prepareConnectionForTransaction ( con , definition ) ; txObject . setPreviousIsolationLevel ( previousIsolationLevel ) ; } else { if ( ( definition . getIsolationLevel ( ) ) != ( TransactionDefinition . ISOLATION_DEFAULT ) ) { throw new InvalidIsolationLevelException ( ( "HibernateTransactionManager<seq2seq4repair_space>is<seq2seq4repair_space>not<seq2seq4repair_space>allowed<seq2seq4repair_space>to<seq2seq4repair_space>support<seq2seq4repair_space>custom<seq2seq4repair_space>isolation<seq2seq4repair_space>levels:<seq2seq4repair_space>" + ( "make<seq2seq4repair_space>sure<seq2seq4repair_space>that<seq2seq4repair_space>its<seq2seq4repair_space>'prepareConnection'<seq2seq4repair_space>flag<seq2seq4repair_space>is<seq2seq4repair_space>on<seq2seq4repair_space>(the<seq2seq4repair_space>default)<seq2seq4repair_space>and<seq2seq4repair_space>that<seq2seq4repair_space>the<seq2seq4repair_space>" + "Hibernate<seq2seq4repair_space>connection<seq2seq4repair_space>release<seq2seq4repair_space>mode<seq2seq4repair_space>is<seq2seq4repair_space>set<seq2seq4repair_space>to<seq2seq4repair_space>'on_close'<seq2seq4repair_space>(SpringTransactionFactory's<seq2seq4repair_space>default)." ) ) ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( ( "Not<seq2seq4repair_space>preparing<seq2seq4repair_space>JDBC<seq2seq4repair_space>Connection<seq2seq4repair_space>of<seq2seq4repair_space>Hibernate<seq2seq4repair_space>Session<seq2seq4repair_space>[" + session ) + "]" ) ) ; } } if ( ( definition . isReadOnly ( ) ) && ( txObject . isNewSession ( ) ) ) { session . setFlushMode ( MANUAL ) ; } if ( ( ! ( definition . isReadOnly ( ) ) ) && ( ! ( txObject . isNewSession ( ) ) ) ) { FlushMode flushMode = session . getFlushMode ( ) ; if ( FlushMode . isManualFlushMode ( session . getFlushMode ( ) ) ) { session . setFlushMode ( AUTO ) ; txObject . getSessionHolder ( ) . setPreviousFlushMode ( flushMode ) ; } } Transaction hibTx ; int timeout = determineTimeout ( definition ) ; if ( timeout != ( TransactionDefinition . TIMEOUT_DEFAULT ) ) { hibTx = session . getTransaction ( ) ; hibTx . setTimeout ( timeout ) ; hibTx . begin ( ) ; } else { hibTx = session . beginTransaction ( ) ; } txObject . getSessionHolder ( ) . setTransaction ( hibTx ) ; if ( ( getDataSource ( ) ) != null ) { Connection con = ( ( org . hibernate . engine . spi . SessionImplementor ) ( session ) ) . connection ( ) ; ConnectionHolder conHolder = new ConnectionHolder ( con ) ; if ( timeout != ( TransactionDefinition . TIMEOUT_DEFAULT ) ) { conHolder . setTimeoutInSeconds ( timeout ) ; } if ( logger . isDebugEnabled ( ) ) { logger . debug ( ( ( "Exposing<seq2seq4repair_space>Hibernate<seq2seq4repair_space>transaction<seq2seq4repair_space>as<seq2seq4repair_space>JDBC<seq2seq4repair_space>transaction<seq2seq4repair_space>[" + con ) + "]" ) ) ; } TransactionSynchronizationManager . bindResource ( getDataSource ( ) , conHolder ) ; txObject . setConnectionHolder ( conHolder ) ; } if ( txObject . isNewSessionHolder ( ) ) { TransactionSynchronizationManager . bindResource ( getSessionFactory ( ) , txObject . getSessionHolder ( ) ) ; } txObject . getSessionHolder ( ) . setSynchronizedWithTransaction ( true ) ; <START_BUG> } catch ( Exception ex ) { <END_BUG> if ( txObject . isNewSession ( ) ) { try { if ( session . getTransaction ( ) . isActive ( ) ) { session . getTransaction ( ) . rollback ( ) ; } } catch ( Throwable ex2 ) { logger . debug ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>rollback<seq2seq4repair_space>Session<seq2seq4repair_space>after<seq2seq4repair_space>failed<seq2seq4repair_space>transaction<seq2seq4repair_space>begin" , ex ) ; } finally { SessionFactoryUtils . closeSession ( session ) ; } } throw new CannotCreateTransactionException ( "Could<seq2seq4repair_space>not<seq2seq4repair_space>open<seq2seq4repair_space>Hibernate<seq2seq4repair_space>Session<seq2seq4repair_space>for<seq2seq4repair_space>transaction" , ex ) ; } } @ Override protected Object doSuspend ( Object transaction ) { } @ Override protected void doResume ( Object transaction , Object suspendedResources ) { } @ Override protected void doCommit ( DefaultTransactionStatus status ) { } @ Override protected void doRollback ( DefaultTransactionStatus status ) { } @ Override protected void doSetRollbackOnly ( DefaultTransactionStatus status ) { } @ Override protected void doCleanupAfterCompletion ( Object transaction ) { } protected boolean isSameConnectionForEntireSession ( Session session ) { } protected DataAccessException convertHibernateAccessException ( HibernateException ex ) { } private class HibernateTransactionObject extends JdbcTransactionObjectSupport { private SessionHolder sessionHolder ; private boolean newSessionHolder ; private boolean newSession ; public void setSession ( Session session ) { } public void setExistingSession ( Session session ) { } public void setSessionHolder ( SessionHolder sessionHolder ) { } public SessionHolder getSessionHolder ( ) { } public boolean isNewSessionHolder ( ) { } public boolean isNewSession ( ) { } public boolean hasSpringManagedTransaction ( ) { } public boolean hasHibernateManagedTransaction ( ) { }

Fix:
} catch ( Throwable ex ) {