使用QueryDSL和Spring Boot查询MonogDB集合字符串[]

时间:2018-11-26 13:55:25

标签: java spring-boot querydsl

我正在努力弄清楚如何使用QueryDSL查询具有String []字段(称为扩展)的mongodb集合。

 @Document
 public class Recording {
   private String from;
   private String to;
   private Date created;
   private String[] extensions;
 }



 public RecordingPagedRequest {

 ...

  private Predicate toPredicate() {

    QRecording recording = QRecording.Recording;

    BooleanBuilder booleanBuilder = new BooleanBuilder();

    if (!StringUtils.isNullOrEmpty(caller)) {
        booleanBuilder.and(recording.from.like("%" + caller + "%"));
    }

    if (!StringUtils.isNullOrEmpty(called)) {
        booleanBuilder.and(recording.to.like("%" + called + "%"));
    }

    if (!StringUtils.isNullOrEmpty(extension)) {
       //What to put here? 
       //booleanBuilder.and(recording.extensions.?????;
    }

    if (start != null) {
        booleanBuilder.and(recording.created.after(start));
    }

    if (end != null) {
        booleanBuilder.and(recording.created.before(end));
    }

    return booleanBuilder.getValue();
 }

}

理想情况下,我希望能够对扩展String []执行类似的查询。

谢谢。

0 个答案:

没有答案