The default MappingMongoConverter adds a custom type key (\"_class\") to each object in the database. So, if I create a Person:
package my.d
So here's the story: we add the type by default as some kind of hint what class to instantiate actually. As you have to pipe in a type to read the document into via MongoTemplate anyway there are two possible options:
Contact and your Person. You could then query for Contacts and we essentially have to determine a type to instantiate.You might be interested in watching this ticket which covers some kind of pluggable type mapping strategy to turn the type information into an actual type. This can serve simply space saving purposes as you might want to reduce a long qualified class name to a hash of a few letters. It would also allow more complex migration scenarios where you might find completely arbitrary type keys produced by another datastore client and bind those to Java types.