I'm trying to make a batch insert with the for each method, I get an exception telling me that I cannot change the running executor type. This is very strange as I have an SQL session so defined:
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
<constructor-arg index="1" value="BATCH" />
</bean>
Either way I'd like to check what's the current executor type to make sure it is a BATCH one. How to do that? I see no method in SQLSession...
In your example sqlSession
is of type SqlSessionTemplate
and it has getExecutorType()
method so you just need to use correct type and have several options to do that
SqlSessionType
instead of plain SqlSession
to the service where you need access to executor typeSqlSession
to SqlSessionTemplate
and then use getExecutorType
SqlSessionType
's property use SPEL to the service like this:
@Value("#{sqlSession.executorType}")
private ExecutorType executorType;