1. ProductDao接口
/**
* 删除商品类别之前,将商品类别id置为空
* @param productCategoryId
* @return
*/
int updateProductCategotyToNull(long productCategoryId);
2. ProductDao.xml实现类
<update id="updateProductCategoryToNull" parameterType="Long">
update tb_product
set product_category_id=null
where product_category_id=#{productCategoryId}
</update>
3. ProductDaoTest测试类
@Test
public void testEUpdateProductCategoryToNull(){
int effectedNum = productDao.updateProductCategoryToNull(9L);
assertEquals(3,effectedNum);
}