在MyBatis中,Result注解用于映射查询结果集中的列到Java对象的属性。Result注解有如下属性:
配置示例:
@Results({
@Result(property = "id", column = "user_id", jdbcType = JdbcType.INTEGER),
@Result(property = "username", column = "user_name", jdbcType = JdbcType.VARCHAR),
@Result(property = "email", column = "user_email", jdbcType = JdbcType.VARCHAR),
@Result(property = "roles", column = "user_id",
many = @Many(select = "com.example.mapper.RoleMapper.findByUserId"))
})
public User findUserById(Integer userId);