title: How to fetch nested document in mongodb
body: <p>I have the following document in mongoDb</p>
  
  <pre><code>{
      "_id" : 0,
      "GroupUuid" : 0,
      "GroupActivationDate" : "2015-08-01T00:00:00.000+05:00",
      "PurchaseDate" : "2015-08-24T12:42:24.380+05:00",
      "GroupExpirationDate" : "2015-08-28T00:00:00.000+05:00",
      "HousefullDate" : "0001-01-01T01:01:00.000+04:28:12",
      "ArtShare" : {
          "TotalArtShares" : 0,
          "pricePerShare" : 0,
          "ArtworkUuid" : 12,
          "AvailableShares" : 0,
          "SoldShares" : 0
      }
  }
  </code></pre>
  
  <p>when I do this  <code>db.groupBuying.find({"ArtShare.TotalArtShares":0}).pretty()</code>
  above document displayed </p>
  
  <p>Now I want to do this using code I am doing like this </p>
  
  <pre><code>val cursor=collection.find()
      var obj=new BasicDBObject
       while(cursor.hasNext)
       {
         obj=cursor.next().asInstanceOf[BasicDBObject]
  
         var id=obj.getString("ArtShare.TotalArtShares").toInt
         log.info("TotalArtShares "+id)
       }
     }
  </code></pre>
  
  <p>But following exception thrown  </p>
  
  <pre><code>java.lang.NumberFormatException: null
      at java.lang.Integer.parseInt(Integer.java:542)
      at java.lang.Integer.parseInt(Integer.java:615)
      at scala.collection.immutable.StringLike$class.toInt(StringLike.scala:247)
      at scala.collection.immutable.StringOps.toInt(StringOps.scala:30)
      at models.groupbuyingmodels.groupbuyingMongoReadWrite.GroupBuyingStore.write(GroupBuyingStore.scala:43)
      at models.groupbuyingmodels.groupbuyingMongoReadWrite.GroupBuyingWriteMongoActor$$anonfun$receive$1.applyOrElse(GroupBuyingWriteMongoActor.scala:27)
      at akka.actor.Actor$class.aroundReceive(Actor.scala:465)
      at models.groupbuyingmodels.groupbuyingMongoReadWrite.GroupBuyingWriteMongoActor.aroundReceive(GroupBuyingWriteMongoActor.scala:15)
      at akka.actor.ActorCell.receiveMessage(ActorCell.scala:516)
      at akka.actor.ActorCell.invoke(ActorCell.scala:487)
      at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:238)
      at akka.dispatch.Mailbox.run(Mailbox.scala:220)
      at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(AbstractDispatcher.scala:393)
      at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
      at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
      at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
      at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
  13:08:55.166 1652348 [ArteciateActorSystem-akka.actor.GroupBuyingWriteMongoActor-dispatcher-6] controller ERROR - printStackTrace()
  </code></pre>
  
  <p>When I do this </p>
  
  <pre><code>var obj=new BasicDBObject
       while(cursor.hasNext)
       {
         //var cur=cursor.next()
         obj=cursor.next().asInstanceOf[BasicDBObject]
  
         var id=obj.getString("GroupUuid").toInt
         log.info("GroupUuid"+id)
       }
     }
  </code></pre>
  
  <p>Then the value of <code>GroupUuid</code> is printed on console 
  how can I fetch <code>TotalArtShares</code> value please help me and where I am doing wrong please guide me </p>