Closed GoogleCodeExporter closed 9 years ago
Seems that Spring tries to close the session because he finds that SqlSession
implements closeable.
But, if I am not wrong, this is just a warning. Isn't it?
Original comment by eduardo.macarron
on 25 Feb 2013 at 9:23
source
MyBatis3.1.1 :public abstract interface SqlSession extends Closeable
MyBatis3.2.0 :public abstract interface SqlSession
Original comment by cobweb1...@gmail.com
on 26 Feb 2013 at 10:52
I do know that, it was me who did the change! :)
The purpose of that change is to support java 7 try-with-resources when using
an SqlSession.
As a side effect, it looks like spring 3.2 (this does not happen in 3.1)
recognizes the interface and tries to close a managed SqlSession
(SqlSessionTemplate) that cannot be closed so it throws an exception indicating
it.
Spring caches the exception so no error reaches de application code.
I was about to nop the .close() in the template to remove the warning but
thought that is is better not to do it because people may think that calling
.close() over a SqlSessionTemplate does something and it does not. So I think
is better that Spring keeps complaining and people know for sure that a
SqlSessionTemplate cannot be closed manually.
Original comment by eduardo.macarron
on 27 Feb 2013 at 5:47
Original comment by eduardo.macarron
on 5 Mar 2013 at 6:34
While I understand Eduardo's comment, I think there should be a way to turn off
the warning. When I write new code, I expect no error and no warning: I want
clean code and the current behavior made jump in my code looking for a fix. I
found nothing, so I starting googling around until I found this issue.
Everybody with the same line of though as me will do the same so we will loose
time for nothing.
Maybe there should be a better message ?
Maybe a method could added to request ignoring silently the close call ?
I would certainly use such method from my junit to make sure there is no
useless warning.
Original comment by MarcGagn...@gmail.com
on 12 Dec 2013 at 2:09
I agree that it is disconcerting to see that error message in the logs. Not
really a fix fix, but here's a workaround that I use to avoid seeing that:
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="clearCache">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
Original comment by james.s....@gmail.com
on 6 Aug 2014 at 7:34
Original issue reported on code.google.com by
cobweb1...@gmail.com
on 20 Feb 2013 at 3:59