a field name “ClassName” is being inserted into mongodb by morphia

前端 未结 2 1804
夕颜
夕颜 2020-12-17 18:15

I\'m pretty new to mongodb and morphia, after starting using it, I realize that there is a extra part in mongodb document, the record contains a filed name \"ClassName\" wit

2条回答
  •  醉酒成梦
    2020-12-17 18:49

    This is normal. Since Morphia supports Polymorphism, means subclasses shall be stored in the same collection where the super class is persisted. In order to differentiate/ filter while querying and storing, it uses this field. Hope you would use Morphia for querying also. How do you think, it affects the integrity of your data, as you could easily filter it out.

    Hibernate too, has discriminator column for supporting polymorphism.

    http://docs.jboss.org/hibernate/core/3.3/reference/en/html/mapping.html#mapping-declaration-discriminator

提交回复
热议问题