Is it somehow possible to set configurable timeout to mybatis mapper?
This works:
<select id="getData" resultType="Data" resultMap="dataMap" timeout="1"><![CDATA[
SELECT * from tab;
]]></select>
But I need to have the timeout configurable, something like
<select id="getData" resultType="Data" resultMap="dataMap" timeout="#{timeout}"><![CDATA[
SELECT * from tab;
]]></select>
Or do I have to implement JDBC prepared statement and set the timeout there?
PreparedStatement stm;
stm.setQueryTimeout(timeOut);
A possible solution is to use a plugin (a.k.a. interceptor).
QueryTimeoutValueis a class that holds aThreadLocal.You can set the timeout value before executing the target statement.