欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jooq使用代码

程序员文章站 2022-05-24 12:31:30
...

1、批量插入

public void saveParamPropValue(List<DbParamPropValue> dbaParamPropValueList) {
        List<InsertValuesStep4<DbParamPropValueRecord, Long, Long, String, String>> inserts = new ArrayList<>();
        dbaParamPropValueList.forEach(item -> {
            InsertValuesStep4<DbParamPropValueRecord, Long, Long, String, String> insert = create.insertInto(
            DB_PARAM_PROP_VALUE,
            DB_PARAM_PROP_VALUE.PARAM_GROUP_ID,
            DB_PARAM_PROP_VALUE.PARAM_ITEM_ID,
            DB_PARAM_PROP_VALUE.ITEM_VALUE,
            DB_PARAM_PROP_VALUE.MYSQL_GROUP_NAME)
            .values(
                item.getParamGroupId(),
                item.getParamItemId(),
                item.getItemValue(),
                item.getMysqlGroupName());
            inserts.add(insert);
        });
        create.batch(inserts).execute();
    }

2、根据参数添加查询条件

public List<DbParamPropValue> queryAll(DbParamPropValue dbParamPropValue) {
        SelectQuery<DbParamPropValueRecord> select = create.selectQuery(DB_PARAM_PROP_VALUE);
        if (StringUtils.isNotBlank(dbParamPropValue.getItemValue())) {
            select.addConditions(DB_PARAM_PROP_VALUE.ITEM_VALUE.eq(dbParamPropValue.getItemValue()));
        }
 }
相关标签: 持久层