2
我使用的是spring-data-mongodb:1.2.0.RELEASE和QueryDSL:2.9.0。使用spring-data和QueryDSL查詢集合屬性大小
我有兩個類A和B如下:
@Document(collection = "A")
public class A {
public BigInteger id;
public Set<B> bSet;
}
@Document(collection = "B")
public class B {
public BigInteger id;
}
和一個倉庫接口:
@Repository
public interface ARepository extends MongoRepository<A, BigInteger>, QueryDslPredicateExecutor<A>
{
}
我想要做的就是讓所有的一個文件,他們的b收藏大小是一定的大小。 所以,我執行一個查詢:
aRepository.findAll(QA.a.bSet.size().loe(1));
和我越來越:
java.lang.UnsupportedOperationException: Illegal operation size(a.bSet)
at com.mysema.query.mongodb.MongodbSerializer.visit(MongodbSerializer.java:204)
at com.mysema.query.mongodb.MongodbSerializer.visit(MongodbSerializer.java:34)
at com.mysema.query.types.expr.NumberOperation.accept(NumberOperation.java:74)
at com.mysema.query.mongodb.MongodbSerializer.asDBValue(MongodbSerializer.java:75)
at com.mysema.query.mongodb.MongodbSerializer.asDBKey(MongodbSerializer.java:71)
at com.mysema.query.mongodb.MongodbSerializer.visit(MongodbSerializer.java:186)
at com.mysema.query.mongodb.MongodbSerializer.visit(MongodbSerializer.java:34)
at com.mysema.query.types.expr.BooleanOperation.accept(BooleanOperation.java:53)
at com.mysema.query.mongodb.MongodbSerializer.handle(MongodbSerializer.java:39)
at com.mysema.query.mongodb.MongodbQuery.createQuery(MongodbQuery.java:362)
at com.mysema.query.mongodb.MongodbQuery.createCursor(MongodbQuery.java:272)
at com.mysema.query.mongodb.MongodbQuery.createCursor(MongodbQuery.java:267)
at com.mysema.query.mongodb.MongodbQuery.list(MongodbQuery.java:253)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:93)
at org.springframework.data.mongodb.repository.support.QueryDslMongoRepository.findAll(QueryDslMongoRepository.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:333)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy68.findAll(Unknown Source)
at com.shunra.server.test.filesmanagement.TestFilesRepository.tmp(TestFilesRepository.java:248)
概括起來講,我需要一個例子/解釋。
門票已添加[此處](https://github.com/mysema/querydsl/issues/436)。 – Modi
我不確定這是否已解決,供您參考,我還在此處創建了一張新票:https://github.com/querydsl/querydsl/issues/2057 – megalucio
我面臨的問題與此類似,但使用聚合。總和()。當量(XX) – tranceholic