javamongodbmorphianosql

How to store null fields with Morphia


Morphia does not store null/empty fields by default. Is there a way to enable this?


Solution

  • In the interests of answering the question asked, you can:

    You can get a MapperOptions reference from the mapper instance by Mapper.getOptions().

    Deprecation Update

    However, the Mapper class is internal only and is deprecated:

    this class will be internalized in 2.0

    Same deprecation applies for before mentioned setter methods in class MapperOptions, instead the JavaDocs recommend:

    use the Builder instead