BsonDiscriminator null value returned

Hi there, I’m using the PojoCodecRegistry and manually setting each class (for some reason the class path scanning does not work if not using class names as the values of the discriminator)

return CodecRegistries.fromProviders(PojoCodecProvider
				.builder()
				.automatic(false)
				.register(Page.class, AdPage.class, CoverPage.class, ContentPage.class, ReviewPage.class)
				.build());

@BsonDiscriminator(key = "type", value = "ads")
public class AdPage extends Page{
}

So, when I run a query in the Pages collection I can see that I get the correct instance for each type of page, however the type property is set to null, and I need that property to be set to be used by the UI.

Does mongo driver ignores the key property? Is there a way to force it to be set during the reads?

Hi @Vinicius_Carvalho,

We’re not sure what’s going on here. Can you open an issue in our Jira with a minimal, reproducible example and we can investigate further?

Thanks,
Jeff