Ich entwickle Anwendung, wo ich Arbeitswoche Zeitplan speichern muss. workSchedule
bestehen aus 7 Tagen (Array), jeden Tag bestehen Array, und dieses Array besteht aus einem anderen Array, wo ich StartTime und EndTime seit Mitternacht speichern.Wie konstruieren Morphium Modell für dieses JSON?
Ich habe versucht, mit List<List<Integer[]>> workSchedule
Mit List<List<List<Integer>>> workSchedule
Mit Integer[][][] workSchedule
aber nichts funktionierte. Es sagt normalerweise BasicBSONList can only work with numeric keys
Wie konstruieren Sie richtiges Modell? Bitte, irgendwelche Vorschläge.
Aktualisiert.
Unter meinem Modell von Mongodb.
{
"_id": {
"$oid": "579dfa208f9c311d327e478a"
},
"status": "approved",
"ratingMinus": 0,
"ratingPlus": 0,
"lat": 55.767166134693,
"lng": 37.59573578997,
"address": "Большая Садовая улица, дом 16, сооружение 1",
"type": "public",
"price": 0,
"isFree": true,
"workSchedule": [
[
[
28800,
72000
]
],
[
[
28800,
72000
]
],
[
[
28800,
72000
]
],
[
[
28800,
72000
]
],
[
[
28800,
72000
]
],
[
[
28800,
72000
]
],
[
[
28800,
72000
]
]
],
"updatedAt": {
"$date": "2016-07-31T13:16:16.454Z"
},
"createdAt": {
"$date": "2016-07-31T13:16:16.454Z"
},
"__v": 0,
"location": [
37.59573578997,
55.767166134693
]
}
Und hier JAVA Eigenschaften:
@Id
private ObjectId id;
private String status;
private int ratingMinus;
private int ratingPlus;
private String address;
@Reference
private WcUser createdBy;
@Reference
private WcUser updatedBy;
private Date createdAt;
private Date updatedAt;
private String routeDetails;
private String type;
private List<List<List<Integer>>> workSchedule;
private boolean isFree;
private int price;
@Indexed(IndexDirection.GEO2D)
private Double[] location;
Und ich versuche, Daten von Mongo wie folgt zu erhalten:
List<WcInstance> wcs = mongoConnectionManager
.getDatastore()
.find(WcInstance.class)
.field("location")
.near(longitude, latitude, 3/111.12)
.limit(100)
.asList();
Und es funktioniert, wenn ich workSchedule
Eigenschaft kommentieren und nicht wenn nicht.
Fehler:
java.lang.RuntimeException: java.lang.IllegalArgumentException: BasicBSONList can only work with numeric keys, not: [size]
finden Sie aktualisierte Version meiner Frage. danke – raiym
Welche Version von Morphia verwendest du? das funktioniert bei mir mit 1.3.0. – evanchooly
Aber 1.3.0 sind noch nicht veröffentlicht. Ich benutze 1.2.1 – raiym