-
Type: New Feature
-
Resolution: Gone away
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Builders
Summary
Updates push/addToSet Does Not Add Discriminator to Subdocuments
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
org.mongodb:mongodb-driver-sync:4.2.3
Mongo 4.4.10 running on Atlas
How to Reproduce
Say if we have the following objects:
public class HDUser { private ObjectId id; private List<Content> contents; }
@BsonDiscriminator(value="Content", key="_cls") public class Content { private ObjectId id; private Metadata metadata; }
@BsonDiscriminator(value="Metadata", key="_cls") public class Metadata { private String name; private Long size; }
If I add a Content with Metadata to an existing HDUser, I expect that Metadata to have a field called "_cls: Metadata" however, I do not see that. Content would have its BsonDiscriminator, but not the subdocument (metadata) within it.
This is what I ran to add the content
Content c = new Content(...) Bson addContent = Updates.addToSet("content", c); Bson updateContentOrder = Updates.addToSet("content_order", c.getId()); return userCollection.updateOne(eq("_id", uid), Updates.combine(addContent, updateContentOrder));
- is related to
-
JAVA-2720 Support Enums in query helpers
- Closed