[JAVA-2608] Allow discriminators to be used in a collection. Created: 21/Sep/17  Updated: 29/Oct/23  Resolved: 04/Dec/17

Status: Closed
Project: Java Driver
Component/s: POJO
Affects Version/s: None
Fix Version/s: 3.6.0

Type: Improvement Priority: Major - P3
Reporter: Ross Lawley Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

PR: https://github.com/mongodb/mongo-java-driver/pull/416

Right now, there is no way to serialize/deserialize a collection of abstract class or interface correctly, even though BsonDiscriminator annotation is added to all relevant classes (i.e. both parent class and all sub-classes). This patch fixes this problem by using the codec of the actual class of the value during encoding instead of the declared class. The decoding already uses a similar process.



 Comments   
Comment by Githook User [ 04/Dec/17 ]

Author:

{'username': 'visualage', 'email': 'qliu@deal.com', 'name': 'Qi Liu'}

Message: Allow discriminators to be used in a collection.

Fixes encoding issue, so that actual codecs for interfaces
or abstract classes are used.

JAVA-2608
Branch: 3.6.x
https://github.com/mongodb/mongo-java-driver/commit/41f8cf0b333d7882a96a8bfb4b10f6dcace45606

Comment by Ross Lawley [ 04/Dec/17 ]

A massive thank you to Qi Liu for the excellent pull request.

Comment by Githook User [ 04/Dec/17 ]

Author:

{'username': 'visualage', 'email': 'qliu@deal.com', 'name': 'Qi Liu'}

Message: Allow discriminators to be used in a collection.

Fixes encoding issue, so that actual codecs for interfaces
or abstract classes are used.

JAVA-2608
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/41f8cf0b333d7882a96a8bfb4b10f6dcace45606

Comment by Ross Lawley [ 28/Nov/17 ]

Extra PR: https://github.com/mongodb/mongo-java-driver/pull/418

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