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

BsonDiscriminator key not populated on reads

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Gone away
    • Icon: Unknown Unknown
    • None
    • None
    • POJO
    • None

    Description

      Summary

      When reading a POJO that has been inserted using the BsonDiscriminator annotation the object maps correctly to the java object but the key value is not populated in the object. In the extended class I would have expected at least the 'value' part of the annotation would have populated the key field with the value.

       

      Server Version : 5.0.15

      Driver Version: mongodb-driver-sync @ 4.9.0

       

      @BsonDiscriminator(key = "type")
      public abstract class Action {
          ActionType type;
      } 

      @BsonDiscriminator(key = "type", value = "SHOT") 
      public class Shot extends Action {
      // Some other fields that successfully populate
      }
      

      Attachments

        Activity

          People

            ross@mongodb.com Ross Lawley
            darrenmatthews776@googlemail.com Darren Matthews
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: