要查询的mongo数据:
{
"_id" : ***,
"_class" : "***",
"downloadCount" : {
"china" : 20,
"google" : 10
}
}
{
"_id" : ***,
"_class" : "***",
"downloadCount" : {
"china" : 10,
"google" : 5
}
}
{
"_id" : ***,
"_class" : "***",
"downloadCount" : {
"china" : 15,
"google" : 2
}
}
查询:
Query query = new Query();
query.with(new Sort(Direction.DESC, "downloadCount.china"));
mongoTemplate.find(query, this.getEntityClass());
错误信息:
java.lang.IllegalAccessError: org/springframework/beans/PropertyMatches
at org.springframework.data.mapping.PropertyReferenceException.detectPotentialMatches(PropertyReferenceException.java:134)
at org.springframework.data.mapping.PropertyReferenceException.<init>(PropertyReferenceException.java:59)
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:291)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:273)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.getPath(QueryMapper.java:837)
at org.springframework.data.mongodb.core.convert.QueryMapper$MetadataBackedField.<init>(QueryMapper.java:729)
查询子文档也是不可以,报相同的错误!!!!
query.addCriteria(Criteria.where("downloadCount.china").is(10));
只有单层的查询和排序是可以正常的,但是我用mongo语句就是可以正常查询和排序的。
跪求大神帮助!!!