java.lang.IllegalArgumentException:BasicBonSonList只能使用数字键,不能:
我正在尝试从集合中获取所有记录。下面是代码供参考java.lang.IllegalArgumentException:BasicBonSonList只能使用数字键,不能:,java,spring,mongodb,spring-security,spring-data,Java,Spring,Mongodb,Spring Security,Spring Data,我正在尝试从集合中获取所有记录。下面是代码供参考 public class ParkingPlace{ @Id private String id; private String placeId; @DateTimeFormat(iso = ISO.DATE_TIME) private Date creationDate; @DBRef private List<Review> placeReviews; //
public class ParkingPlace{
@Id
private String id;
private String placeId;
@DateTimeFormat(iso = ISO.DATE_TIME)
private Date creationDate;
@DBRef
private List<Review> placeReviews;
// Getters and setters
}
public class Review{
@Id
private String id;
@DBRef
private Author reviewAuthor;
//getters and setters
}
public class Author{
@Id
private String id;
private String fullName;
//getters and setters
}
public class ParkingPlaceDAO{
@Autowired
MongoOperations mongoOperations;
public List<ParkingPlace> getAllPlaces() {
// new mongodb query
Query query = new Query();
// sort by date
query.with(new Sort(Sort.Direction.DESC, "creationDate"));
// run query
return mongoOperations.find(query, ParkingPlace.class);
}
}
我已经检查了数据库和所有集合,还从mongo shell启动了查询,它给了我结果。但不是通过代码可以显示ParkingPlace类吗?@conceptQuuest update我已经尝试了最新的Spring mongo版本1.10.4.RELEASE。。。我无法重现这个问题。能否显示停车场文档(及其相应的审阅和编写文档)的收集数据。
java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [reviewAuthor]