riferendosi la postare How to add an array to a MongoDB document using Java? ho creato uno schema mongo utilizzando Java ha elementi secondari, che sto ottenendo _id
per documento principale vorrei ottenere _id
in elementi secondari anche qui sguardi di uscita (ho segnato la parte in cui ho bisogno _id
) b.party.find().pretty();
come creare MongoDB IDOggetto in java
{
"_id" : ObjectId("5399aba6e4b0ae375bfdca88"),
"addressDetails" : [
{
// _id here
"locationName" : "Office",
"phones" : [
{ // _id here
"name" : "Tel1",
"value" : "95253-"
},
{ // _id here
"name" : "Tel2",
"value" : "95253-"
},
{ // _id here
"name" : "Tel3",
"value" : "95253-"
},
{ // _id here
"name" : "Fax1",
"value" : "0253-"
}
],
"address" : "A-3,MIDCA-3,MIDC",
"defaultBillAddrerss" : "",
"pincode" : "422 010",
"city" : null,
"state" : "1",
"country" : ""
},
{ // _id here
"locationName" : "Factory",
"phones" : [
{ // _id here
"name" : "Tel1",
"value" : "0253-"
},
{ // _id here
"name" : "Tel2",
"value" : "0253-"
},
{ // _id here
"name" : "Tel3",
"value" : "0253-"
},
{ // _id here
"name" : "Fax1",
"value" : "0253-"
}
],
"address" : "A-3 INDUSTRIAL AREA,",
"defaultBillAddrerss" : "",
"pincode" : "422 010",
"city" : null,
"state" : "1",
"country" : ""
}
],
"crLimit" : "0.0",
"crPeriod" : "",
"name" : "CROMPTON GREAVES "
}
codiceJava per creare è simile a How to add an array to a MongoDB document using Java?
Esiste un codice per creare ObjectId("")
in modo programmatico in java?
l'obbiettivo è c reated quando si inserisce un oggetto nel database. – njzk2
@ id njzk2 viene creato automaticamente per i documenti padre, sono interessato a ottenere id per i sotto elementi – AmeyChavan