Currently it seems annotations from interfaces aren't picked up:
Interface: @BsonDiscriminator public interface Pet { String getType(); } public class Cat implements Pet { private String name; // ... }
MongoCollection<Pet>.insertOne(cat) inserts but no Discriminator field is stored.
Where as if its on the class it is picked up:
public interface Pet { String getType(); } @BsonDiscriminator public class Cat implements Pet { private String name; // ... }
And here: MongoCollection<Pet>.insertOne(cat) inserts but the Discriminator field is stored!
- is related to
-
JAVA-5370 Add PojoCodec support for discriminator look ups on interfaces / abstract classes
- Backlog