can数为null 会怎么拼接到sql语句

   /**
     * 分页分表模糊查询
     * @param name
     * @param productNo
     * @return
     */
    @Select("select a.id,a.name, a.product_no productNo,b.name category,a.description from t_product a join t_type b on a.type_id=b.id where a.status=1 and  a.product_no like '%${productNo}%' and a.`name` like '%${name}%'")
    List<Product> multiselectAllProduct(@Param("name") String name,@Param("productNo") String productNo);
```若传入参数 name  为null   则  拼接的sql语句如下

@Select("select a.id,a.name, a.product_no productNo,b.name category,a.description from t_product a join t_type b on a.type_id=b.id where a.status=1 and  a.product_no like '%${productNo}%' and false"

"and false 在拼接时会被自动省略"

猜你喜欢

转载自blog.csdn.net/bryangp/article/details/112919693