title: javax.persistence.TransactionRequiredException no transaction is in progress
body: <p>I am using a java app with hibernate 5 and spring 5</p>
  <p>I am upgrading spring and hibernate from older versions to the specified ones.</p>
  <p>I had a problem with createCriteria &quot; createCriteria is not valid without active transaction&quot; and as I am using a transaction manager, I fixed it with removing the following hibernate property</p>
  <pre><code>hibernate.current_session_context_class=thread
  </code></pre>
  <p>Now the criteria.list() method works fine and I get the result inside my DAO</p>
  <p>This DAO is called by a service and it should return the result, Except it doesn't, I get this error</p>
  <pre><code>javax.persistence.TransactionRequiredException no transaction is in progress
  </code></pre>
  <p>When I debugged, right after the return  I found that there's a method being called:</p>
  <blockquote>
  <p>commitTransactionAfterReturning(@Nullable TransactionInfo info)</p>
  </blockquote>
  <p>inside</p>
  <blockquote>
  <p>TraansactionAspectSupport.java (spring-tx 5.2.2)</p>
  </blockquote>
  <p>which calls a series of method to finally call session.flush(). So this is all done by the transaction manager.</p>
  <p>And I noted that just after the session.flush() I get that error.</p>
  <p>Now I can't remove that as it's done by the transaction manager (I saw other threads advising to do so but it's not possible for my case)</p>
  <p>I have a XML config:</p>
  <pre><code>&lt;bean id=&quot;demo.transactionManager&quot;
  class=&quot;org.springframework.orm.hibernate5.HibernateTransactionManager&quot;
  &lt;property name=&quot;sessionFactory&quot;
  &lt;ref bean = demo.dessionFactory&quot;/&gt;
  &lt;/bean&gt;
  </code></pre>
  <p>These are the hibernate properties I am using</p>
  <blockquote>
  <p>demo.hibernateProperties.hibernate.dialect
  org.hibernate.dialect.SysBaseDialect
  demo.hibernateProperties.hibernate.show_sql false
  demo.hibernateProperties.hibernate.format_sql true
  demo.hibernateProperties.hibernate.use_sql_comments false
  demo.hibernateProperties.hibernate.generate_statistics false
  demo.hibernateProperties.hibernate.cache.provider_class
  demo.hibernateProperties.hibernateorg.hibernate.cache.HashtableCacheProvider
  demo.hibernateProperties.hibernate.cache.use_second_level_cache false
  demo.hibernateProperties.hibernate.connection.autocommit true
  demo.hibernateProperties.hibernate.transaction.auto_close_session
  false
  demo.hibernateProperties.hibernate.byteècode.use_reflection_optimizer
  false demo.hibernateProperties.hibernate.query.sustitutions true'Y',
  false 'N' demo.hibernateProperties.hibernateconnection.release_mode
  after_statement
  demo.hibernateProperties.hibernate.flush_before_completion true
  demo.hibernateProperties.hibernate.query.factory_class
  org.hibernate.hql.classic.ClassicQueryTranslatorFactory
  demo.hibernateProperties.hibernate.ejb.metamodel.population disabled</p>
  </blockquote>