mybatis cursor "A Cursor is already closed." error msg although transactional is defined

1.9k Views Asked by At

Mapper:

@SelectProvider(type = Provider.class, method = "retrieveTx")
        @Results(value = {
            @Result(property = "transactionId", column = "transaction_id", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
        Cursor<TxModel> retrieveTx(String id);

DAO/Repository:

@Transactional(readOnly = true)
    public Cursor<TxModel> retrieveTx(String id) {
        return mapper.retrieveTx(id);
    }

Implementation:

private Result calTx() {
    Cursor txs = testDao.retrievetx(1);
}

I added @Transactional to the DAO, but I get err:

"A Cursor is already closed." at org.apache.ibatis.cursor.defaults.DefaultCursor.iterator(DefaultCursor.java:100) ~[mybatis-3.5.6.jar:3.5.6] DefaultCursor.java:100

I also add @Transactional to the operation, still not successful

@Transactional
private Result calTx() {
        Cursor txs = testDao.retrievetx(1);
    }
0

There are 0 best solutions below