• 首页
  • 产品中心
    • 数式Oinone四大产品

      低代码开发平台无代码开发平台集成开发平台AI大模型开发
    • 数式Oinone体系能力

      用户与组织权限管理文件管理消息中心国际化业务审计
    • 数式Oinone核心产品特性

      低无一体面向软件公司场景无限制应用级扩容可分可合
  • 服务中心
    • 客户服务

      预约演示方案咨询私有部署找人定制
    • 开发者

      问答下载
    • Oinone学院

      社区学习

    《精讲面向软件公司的低代码平台——以Oinone为例》

  • 合作伙伴
    渠道申请伙伴名录专家库
  • 关于数式
0571-88757863

Data Operation:Usage of IWrapper, QueryWrapper, and LambdaQueryWrapper


Ⅰ. Conditional Update (updateByWrapper)

Normally, when performing an update, we create a new object to reduce the number of fields being updated.

Integer update = new DemoUser().updateByWrapper(new DemoUser().setFirstLogin(Boolean.FALSE),
                                                Pops.<DemoUser>lambdaUpdate().from(DemoUser.MODEL_MODEL).eq(IdModel::getId, userId));

Method to update specified fields using the updateById method of the base model:

  • Create a new update object and update this object.
WorkflowUserTask userTaskUp = new WorkflowUserTask();
userTaskUp.setId(userTask.getId());
userTaskUp.setNodeContext(json);
userTaskUp.updateById();

Ⅱ. Conditional Deletion (updateByWrapper)

public List<T> delete(List<T> data) {
    List<Long> petTypeIdList = new ArrayList<>();
    for (T item : data) {
        petTypeIdList.add(item.getId());
    }
    Models.data().deleteByWrapper(Pops.<PetType>lambdaQuery().from(PetType.MODEL_MODEL).in(PetType::getId, petTypeIdList));
    return data;
}

Ⅲ. Construct Conditional Query Data

  • Example 1: LambdaQueryWrapper to concatenate query conditions
private void queryPetShops() {
    LambdaQueryWrapper<PetShop> query = Pops.<PetShop>lambdaQuery();
    query.from(PetShop.MODEL_MODEL);
    query.setSortable(Boolean.FALSE);
    query.orderBy(true, true, PetShop::getId);
    List<PetShop> petShops2 = new PetShop().queryList(query);
    System.out.printf(petShops2.size() + "");
}
  • Example 2: IWrapper to concatenate query conditions
private void queryPetShops() {
    IWrapper<PetShop> wrapper = Pops.<PetShop>lambdaQuery()
    .from(PetShop.MODEL_MODEL).eq(PetShop::getId, 1L);
    List<PetShop> petShops4 = new PetShop().queryList(wrapper);
    System.out.printf(petShops4.size() + "");
}
  • Example 3: QueryWrapper to concatenate query conditions
private void queryPetShops() {
    // Use Lambda to get the field name to prevent missing changes when modifying the field name later
    String nameField = LambdaUtil.fetchFieldName(PetTalent::getName);
    // Use Lambda to get the column name to prevent missing changes when modifying the field name later
    String nameColumn = PStringUtils.fieldName2Column(nameField);
    QueryWrapper<PetShop> wrapper2 = new QueryWrapper<PetShop>().from(PetShop.MODEL_MODEL)
    .eq(nameColumn, "test");
    List<PetShop> petShops5 = new PetShop().queryList(wrapper2);
    System.out.printf(petShops5.size() + "");
}

Convert IWrapper to LambdaQueryWrapper

@Function.Advanced(type = FunctionTypeEnum.QUERY)
@Function.fun(FunctionConstants.queryPage)
@Function(openLevel = {FunctionOpenEnum.API})
public Pagination<PetShopProxy> queryPage(Pagination<PetShopProxy> page, IWrapper<PetShopProxy> queryWrapper) {
    LambdaQueryWrapper<PetShopProxy> wrapper = ((QueryWrapper<PetShopProxy>) queryWrapper).lambda();
    // Get non-stored fields from QueryData
    Map<String, Object> queryData = queryWrapper.getQueryData();
    if (null != queryData && !queryData.isEmpty()) {
        String codes = (String) queryData.get("codes");
        if (org.apache.commons.lang3.StringUtils.isNotBlank(codes)) {
            wrapper.in(PetShopProxy::getCode, codes.split(","));
        }
    }

    return new PetShopProxy().queryPage(page, wrapper);
}
Edit this page
Last Updated:1/15/26, 4:02 AM
Prev
Data Operation:Batch Excel Import
Next
Data Operation:Oinone External Data Source Connection Solution
默认页脚
Copyright © 2026 Mr.Hope