結果映射配置: 原來xml中的<resultMap>對應 @resultssql
@Select("select * from t_account where id = #{id}") @Results(id = "accountMap", value = { @Result(id = true, column = "id", property = "id"), @Result(column = "user_id", property = "user", one = @One( select = "cn.ann.mapper.UserMapper.getUserById", fetchType = FetchType.EAGER )) }) Account getAccountById(Integer id);
@Result(id = true, column = "id", property = "id")
@Select("select * from t_user where id = #{id}") @Results(id = "userMap", value = { @Result(id = true, property = "id", column = "id"), @Result(property = "accounts", column = "id", many = @Many(select = "cn.ann.mapper.AccountMapper.getAccountsByUserId", fetchType = FetchType.LAZY)) }) User getUserById(Integer id);
@ResultMap("accountMap")