title: how to create mongoDB objectid in java
body: <p>Refering to post <a href="https://stackoverflow.com/questions/15371839/how-to-add-an-array-to-a-mongodb-document-using-java">How to add an array to a MongoDB document using Java?</a>
  I have created a mongo schema using java
  it has sub elements, I am getting <code>_id</code> for main document 
  I would like to get <code>_id</code> in sub elements also here output looks (I have marked the portion where I need <code>_id</code>)  <code>b.party.find().pretty();</code></p>
  
  <pre><code>{
  
  "_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  "
  </code></pre>
  
  <p>}</p>
  
  <p>Java code to create is similar to  <a href="https://stackoverflow.com/questions/15371839/how-to-add-an-array-to-a-mongodb-document-using-java">How to add an array to a MongoDB document using Java?</a></p>
  
  <p>Is there any code to create <code>ObjectId("")</code> programmatically in java?</p>