Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5371

Pojos should inherit annotations from interfaces

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: POJO
    • Java Drivers

      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!

            Assignee:
            Unassigned Unassigned
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: