Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1837

Add support for polymorphic persistence

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: None
    • Component/s: Codecs
    • Labels:
      None

      when saving an object, we need to support the serialization of subclasses and their hydration regardless of the field type declaration. e.g.

      List<Person> might hold Person, an Manager, or a Contractor. The code will need be able to apply the correct Codec to and from the database.

      A discriminator value would be added to the saved document. With the Conventions system in place, how this is defined could configurable.

      The C# driver uses an array of discriminator values to support subclasses and polymorphia queries:

      For example:

      { _t : [ "Animal", "Mammal", "Cow" ], ... }

      This form of discriminator is very useful for querying on types in the middle of the inheritance hierarchy:

      db.animals.find({ _t : "Mammal" });

            Assignee:
            justin.lee Justin Lee
            Reporter:
            justin.lee Justin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: