title: ObjectIds don't get retrieved from collection (Scala + MongoDB)
body: <p>There is a MongoDB instance on my computer with a database. A couple of documents are present in one of the collections, I inserted them manually. There is a Scala application to manipulate the database. There is a case class called Location.</p>
  
  <pre><code>case class Location(_id: Option[ObjectId] = None, name: String) {
    var visible: Boolean = false
  }
  </code></pre>
  
  <p>This is the MongoDB configuration in the application.</p>
  
  <pre><code>private val customCodecs = fromProviders(
    classOf[Location]
  )
  private val javaCodecs =
      fromCodecs(new LocalDateTimeDateCodec(), new LocalDateDateCodec())
  
  private val codecRegistry =
    fromRegistries(customCodecs, javaCodecs, 
    DEFAULT_CODEC_REGISTRY)
  val dbConnection = MongoClient(dbURI)
  
  val database: MongoDatabase = dbConnection.getDatabase(dbName).withCodecRegistry(codecRegistry)
  </code></pre>
  
  <p>There are more <code>classOf</code> definitions in the <code>customCodecs</code>, just removed them. The <code>dbURI</code> string is retrieved from a config file.
  There is a controller endpoint, which returns all Locations from the database. The result is this:</p>
  
  <pre><code>[{"_id":{},"name":"Hungary","visible":false},{"_id":{},"name":"Germany","visible":false},{"_id":{},"name":"France","visible":false},{"_id":{},"name":"Switzerland","visible":false},{"_id":{},"name":"Poland","visible":false}]
  </code></pre>
  
  <p>The documents in the database have ObjectId, since I entered them manually, and some documents should have the <code>visibility</code> property true. I suspect there is something wrong with the JSON serialization, but cannot figure it out what.
  This is the code which queries the collection.</p>
  
  <pre><code>val query = collection.find().toFuture()
  Await.result(query, 10.seconds).toList
  </code></pre>
  
  <p>The service method calls this code and passes the result to the controller.</p>
  
  <pre><code>import org.json4s.native.Serialization.write
  val languages = enrollmentService.getAllLanguages
      logger.info("GET all languages")
      Ok(Json.parse(write[List[Language]](languages)))
  </code></pre>
  
  <p>I use json4s for JSON serialization / deserialization.</p>
  
  <p>What could be the issue here?</p>