Spring JDBC support and large dataset

前端 未结 5 697
眼角桃花
眼角桃花 2020-12-14 02:56

When using one of the various JDBC template methods I am confused on how to iterate/scroll over large result sets (which won\'t fit into memory). Even without a direct expos

5条回答
  •  爱一瞬间的悲伤
    2020-12-14 03:20

    You may use springjdbc-iterable library:

    CloseableIterator iter = jt.queryForIter("select ...", params, mapper);
    

    Iterator will be auto-closed on exhaustion or may be closed manually. It will work only within transaction bounds.

    Disclaimer: I wrote this library

提交回复
热议问题