美文网首页
querydsl and or 组合查询

querydsl and or 组合查询

作者: 逗不一样 | 来源:发表于2020-12-16 19:38 被阅读0次

    1. 复杂查询

    参考官方文档:http://www.querydsl.com/static/querydsl/latest/reference/html/ch03.html#d0e2023

    样例:

    BooleanBuilder builder =new BooleanBuilder();

    if (findHouseNewHouseQuery.getCityId() !=null) {

    builder.and(qHouseNewRoomTypeDealStatistics.cityId.eq(findHouseNewHouseQuery.getCityId()));

    }

    List quotedPriceList = findHouseNewHouseQuery.getQuotedPriceList();

    if (CollectionUtils.isNotEmpty(quotedPriceList)) {

    BooleanBuilder quotedPriceBuilder =new BooleanBuilder();

    for (NewHouseOperateOb newHouseOperateOb : quotedPriceList) {

    quotedPriceBuilder.or(qHouseNewRoomTypeDealStatistics.minTotalPrice.goe(newHouseOperateOb.getStartValue()).and(qHouseNewRoomTypeDealStatistics.minTotalPrice.lt(newHouseOperateOb.getEndValue())));

    }

    builder.and(quotedPriceBuilder);

    }

    相关文章

      网友评论

          本文标题:querydsl and or 组合查询

          本文链接:https://www.haomeiwen.com/subject/jeeogktx.html