MyBatisで「A Cursor is already closed.」が出たときの対処法をメモしておきます。 環境 @Transactionalを付与する MyBatisでCursorを使うときは、セッションをオープンしてやる必要があります。具体的には、Cursorを使うメソッドに@Transactionalを付与してやればOKです。 以下のように、データベースからレコードを1件ずつ読み込む処理では、@Transactional(readOnly = true)を付与してあげましょう。 まとめ MyBatisで「A Cursor is already closed.」が出たときの対処法でした。 参考リンク Empty Iterator returned on Cursor when it is already closed · Issue #1297 · mybatis/mybatis
![MyBatisで「A Cursor is already closed.」が出たときの対処法 - Reasonable Code](https://cdn-ak-scissors.b.st-hatena.com/image/square/b4132d705e184f19340f0ca5167aeb916284f002/height=288;version=1;width=512/https%3A%2F%2Freasonable-code.com%2Fwp-content%2Fuploads%2F2019%2F03%2Ficons8.png)