//在userMapper里:
@Results({
@Result(property = "id", column = "id"),
@Result(property = "username", column = "username"),
@Result(property = "orders", column = "uid", javaType = List.class,
many = @Many(select = "OrderMapper.findOrderByUserId"))
})
@Select("select * from User")
public List<Order> findUserAndOrders();
//在orderMapper里:
@Select("select * from orders where user_id = #{userId}")
public User findOrderByUserId(Integer userId);
网友评论