slyak / spring-data-jpa-extra

spring data jpa with template dynamic query (eg: freemarker,velocity etc.) like mybatis. The master branch already support springboot2+ spring5+
Apache License 2.0
400 stars 116 forks source link

using local thread call @TemplateQuery method, the Unable to acquire Connection excp occurs #12

Closed wolfJ closed 6 years ago

wolfJ commented 7 years ago

If i using local thread(new Thread) call @TemplateQuery serviceMethod do some query, then the exception occurs. exception info: org.springframework.orm.jpa.JpaSystemException: Unable to acquire JDBC Connection; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection

But i found, when add @Transactional(readOnly = true) on the serviceMethod, it works!

stormning commented 6 years ago

Thanks for @wolfJ, he create a patch for com.slyak.spring.jpa.FreemarkerTemplateQuery which return original proxy Query instead of raw and solve the problem.