例如 在这段代码中
queryWrapper.eq(dish.getCategoryId() != null ,Dish::getCategoryId,dish.getCategoryId());
dish.getCategoryId() != null 这是判断条件, 成立再执行后面 Dish::getCategoryId,dish.getCategoryId()
其中
Dish::getCategoryId是方法的引用,这是数据库中的 categoryId
字段在Java代码中的“引用”或“标识”
dish.getCategoryId()是方法的调用,是从特定 Dish
对象中获取的实际 categoryId
值。
Dish::getCategoryId
并不“接收”或“存储”dish.getCategoryId()
的返回值。相反,Dish::getCategoryId
只是一个标识符,用于告诉 MyBatis-Plus 你想比较哪个字段,而 dish.getCategoryId()
提供的值则是你想与数据库中该字段的值进行比较的值
你是在告诉 MyBatis-Plus:在生成的 SQL 查询中,我想比较 (Dish::getCategoryId) categoryId
字段的值是否等于(dish.getCategoryId()) dish
对象的 categoryId
值。