I have a mongo collection that has an embedded array of ObjectId's, so the general format is this:
{
"_id" : ObjectId("123abc..."),
"Active" : [
{
"Id" : ObjectId("123abc...")
},
{
"Id" : ObjectId("123abc...")
},
...,
{
"Id" : ObjectId("123abc...")
}
],
"field1" : "blah blah",
"field2" : "blah blah",
"field3" : "blah blah",
"field4" : "blah blah"
"field5" : ObjectId("123abc...")
}
My Java class is pretty simple:
@Document(collection="MyCollection")
public class MyCollection {
@Id
private ObjectId id;
private String field1;
...
private ObjectId field5;
@Field("Active")
private List<Active> active;
// Getters & Setters here
public static class Active {
@Field("Id")
private ObjectId id;
public ObjectId getId() {
return id;
}
public void setId(ObjectId id) {
this.id = id;
}
}
}
When I do the query, everything comes over correctly but the "Active" field. If there are 18 entries in that array, I will get a List of size 18, but the 18 entries of Active.class are all null - so it gets that it's a List, it just never pulls over the ObjectId values within the active array.
I'm using Spring and the Spring mongo driver.
Aucun commentaire:
Enregistrer un commentaire