KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
The default MappingMongoConverter adds a custom type key ("_class") to each object in the database. So, if I create a Person: package my.dto; public class Person { String name; public Person(String name) { this.name = name; } } and save it to the db: MongoOperations ops = new MongoTemplate(new Mongo(), "users"); ops.insert(new Person("Joe")); the resulting object in the mongo will be: { "_id" : ObjectId("4e2ca049744e664eba9d1e11"), "_class" : "my.dto.Person", "name" : "Joe" } Questions: What are the implications of moving the Person class into a different namespace? Is it possible not to pollute the object with the "_class" key; without writing a unique converter just for the Person class?
Tags (comma-separated)
Save Edits
Cancel