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

Add support for polymorphic persistence

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • Component/s: Codecs
    • Labels:
      None
    • Sprint:
      JVM Sprint 33, JVM Sprint 34

      Description

      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" });

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved: