阅读量:109
在 MyBatis 中,可以使用 元素或者 @Results 注解来设置 ResultSetType。
- 使用
元素:
<resultMap id="yourResultMap" type="yourResultType" resultSetType="FORWARD_ONLY">
<!-- 在这里定义结果映射 -->
</resultMap>
- 使用
@Results注解:
@Results(id = "yourResults", value = {
@Result(property = "yourProperty", column = "yourColumn", jdbcType = JdbcType.VARCHAR),
// 在这里定义其他结果映射
}, resultSetType = ResultSetType.SCROLL_SENSITIVE)
在上面的例子中,resultSetType 属性可以设置为以下几种值:
ResultSetType.FORWARD_ONLY:结果集的游标只能向前移动,不支持滚动。ResultSetType.SCROLL_SENSITIVE:结果集的游标可以向前或向后滚动,对于结果集的更改会反映到结果集中。ResultSetType.SCROLL_INSENSITIVE:结果集的游标可以向前或向后滚动,但对结果集的更改不会反映到结果集中。