title: "JDBC transaction marked for rollback-only" exception during application startup
body: <p>I am trying to make migration from Hibernate 5.1.0 to 5.2.1. 
  During application startup, when I was using 5.1.0 there was a lot of warnings, which I did not care much. The warnings were like:</p>
  
  <pre><code>DEBUG org.hibernate.jpa.spi.AbstractEntityManagerImpl [localhost-startStop-1] Mark transaction for rollback
  </code></pre>
  
  <p>I am using Spring 4.3.2 and Tomcat 8. After Hibernate migration to 5.2.1 the application started throwing lots of exceptions. They appear only at startup. Then everything works ok. The exceptions are:</p>
  
  <pre><code>DEBUG org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl [localhost-startStop-1] JDBC transaction marked for rollback-only (exception provided for stack trace)
  java.lang.Exception: exception just for purpose of providing stack trace
      at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.markRollbackOnly(JdbcResourceLocalTransactionCoordinatorImpl.java:254) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.engine.transaction.internal.TransactionImpl.setRollbackOnly(TransactionImpl.java:143) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.Transaction.markRollbackOnly(Transaction.java:68) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.internal.AbstractSharedSessionContract.markForRollbackOnly(AbstractSharedSessionContract.java:340) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:165) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.internal.AbstractSharedSessionContract.buildQueryFromName(AbstractSharedSessionContract.java:729) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at org.hibernate.internal.AbstractSharedSessionContract.createNamedQuery(AbstractSharedSessionContract.java:709) [hibernate-core-5.2.1.Final.jar:5.2.1.Final]
      at sun.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) ~[?:?]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77]
      at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347) [spring-orm-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at com.sun.proxy.$Proxy84.createNamedQuery(Unknown Source) [?:?]
      at org.springframework.data.jpa.repository.query.NamedQuery.hasNamedQuery(NamedQuery.java:99) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.data.jpa.repository.query.NamedQuery.lookupFrom(NamedQuery.java:121) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$DeclaredQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:212) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:77) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:435) [spring-data-commons-1.12.2.RELEASE.jar:?]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:220) [spring-data-commons-1.12.2.RELEASE.jar:?]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:266) [spring-data-commons-1.12.2.RELEASE.jar:?]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:252) [spring-data-commons-1.12.2.RELEASE.jar:?]
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92) [spring-data-jpa-1.10.2.RELEASE.jar:?]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:187) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1213) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1053) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1018) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:349) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:775) [spring-beans-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.__refresh(AbstractApplicationContext.java:541) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java) [spring-context-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) [spring-web-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) [spring-web-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.3.1.RELEASE.jar:4.3.1.RELEASE]
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4811) [catalina.jar:8.0.33]
      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5251) [catalina.jar:8.0.33]
      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [catalina.jar:8.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) [catalina.jar:8.0.33]
      at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) [catalina.jar:8.0.33]
      at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_77]
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_77]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_77]
      at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]
  </code></pre>
  
  <p>Every exception looks the same.
  What makes those exceptions are thrown?</p>