public void main(String[] args) {
//修改方法
String unitId = "1";
//将UnitCompanyCategory表下UnitId值为1对应的unitCategoryId字段数据改为1
String categoryId = "1";
LambdaUpdateWrapper<UnitCompanyCategory> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
lambdaUpdateWrapper.set(UnitCompanyCategory::getUnitCategoryId, categoryId);
lambdaUpdateWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
this.update(lambdaUpdateWrapper);
//以下为查和删除方法
//根据unitId查询一个对象,有多个会报错
LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
UnitCompanyCategory unitCompanyCategory = this.getOne(lambdaQueryWrapper);
//查询UnitCompanyCategory表下unitId为1的数据返回List
LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
List<UnitCompanyCategory> list = this.list(lambdaQueryWrapper);
//删除UnitCompanyCategory表下企业unitId为1的数据
LambdaQueryWrapper<UnitCompanyCategory> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(UnitCompanyCategory::getUnitId, unitId);
baseMapper.delete(lambdaQueryWrapper);
}
LambaQueryWrapper的经常使用方法(修改、查询、删除)
于 2022-01-11 14:54:06 首次发布