[JAVA-1837] Add support for polymorphic persistence Created: 22/May/15  Updated: 05/Jun/17  Resolved: 18/Jul/16

Status: Closed
Project: Java Driver
Component/s: Codecs
Affects Version/s: None
Fix Version/s: 3.5.0

Type: New Feature Priority: Major - P3
Reporter: Justin Lee Assignee: Justin Lee
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: POJO

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


Generated at Thu Feb 08 08:55:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.