spring batch中MyBatisPagingItemReader分页使用介绍
假如是mysql的话,SQL语句
<![CDATA[
select * from ( SELECT so.* FROM t_tm_sales_order so where so.last_modified_time >= to_timestamp('2015-05-05','yyyy-mm-dd hh24:mi:ss') order by so.id limit #{_pagesize} OFFSET #{_skiprows} ) temp_a inner join t_tm_sales_order_line sol on temp_a.id=sol.so_id
]]>
假如是oracle的话,SQL语句
<![CDATA[ select t2.* from (select t1.*,rownum rn from (select * from a) t1 where rownum<= (#{_pagesize} + #{_skiprows})) t2 where t2.rn > #{_skiprows} ]]>
xml配置:
<bean id="itemReader" class="org.mybatis.spring.batch.MyBatisPagingItemReader" scope="step"> <property name="sqlSessionFactory" ref="sqlSessionFactory" /> <property name="pageSize" value="1000"/> <property name="queryId" value="com.jr.gyl.base.pay.app.dao.erp.OpenLinkDao.queryByMutliParams" /> <property name="parameterValues"> <map> <entry key="companyName" value="#{jobParameters['companyName']}"> </entry> <entry key="companyNo" value="#{jobParameters['companyNo']}"> </entry> <entry key="startTime" value="#{jobParameters['startTime']}"> </entry> <entry key="openBank" value="#{jobParameters['openBank']}"> </entry> <entry key="endTime" value="#{jobParameters['endTime']}"> </entry> <entry key="pageSize" value="#{jobParameters['pageSize']}"> </entry> </map> </property> </bean>