2013-12-16 50 views
3

我有一个实体文档与DocumentValue的Querydsl路径深度

@QueryEntity 
@Document 
public class Document{ 
private List<DocumentValue> documentValues; 
} 

DocumentValue可以列表也有DocumentValue列表

@QueryEntity 
public class DocumentValue { 
String value; 
String name; 
String id; 
List<DocumentValue> documentValues; 
} 

我现在试图做类似

private QDocumentValue getDocumentValuePathByDepth(int depth){ 
       ListPath path = QDocument.document.documentValues; 
       if (depth != null) { 
      for (int i = 0; i < depth; i++) { 
       path = path.documentValues.any(); 
      } 
     } 
} 

有没有人知道它是否有可能在这个深度做eleMatch?

就像在深度documentValues应该满足两个条件

BR DC

ListPath<QDocumentValue> query = getDocumentValuePathByDepth(5); 
return query.fieldId.eq(documentFilter.getFieldId()).and(query.value.between(from, to)); 

一个要素

回答

1

elemMatch在Querydsl MongoDB的支持这样

QDocumentValue documentValue = QDocumentValue.documentValue; 
query.anyEmbedded(document.documentValues, documentValue) 
    .on(documentValue.id.eq(documentFilter.getFieldId(), 
     documentValue.value.between(from, to)); 
+0

任何建议,我的实际问题? – DanDiesel

+0

看到下面的答案 – DanDiesel

+0

你没有在你的问题中提到elemMatch。也许更新也是这个问题? –