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

"Top level classes with generic types are not supported by the PojoCodec." Should not be unsupported

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 5.1.2
    • Affects Version/s: None
    • Component/s: POJO
    • None
    • Fully Compatible
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      I have the following class:

       

      @BsonDiscriminator
      public abstract class InventoryItem<S extends Stored, C, W extends StoredWrapper<C, S>> extends ImagedMainObject {
      ...
      

      This class is never stored as this abstract type, though it is this type that is given to my Mongo collection.

      Each subclass that is given has each of these generics defined and specialized, and only those concrete subclasses are saved.

       However, this now results in the following error when pulling objects out of the database (putting in is fine):

      org.bson.codecs.configuration.CodecConfigurationException: InventoryItem contains generic types that have not been specialised. 

      This is a new error, as earlier versions of the codec did not produce this, and breaks my setup when moving to the newer codec.
      Is this a regression? Result of new changes to the codec?

      I feel the codec should be a little smarter, and is currently being rather preemptive by disallowing based on anything related to superclass, especially when `@BsonDiscriminator` is at play. The codec should know exactly which class is being pulled out of the database and handle accordingly.

       

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            contact@gjstewart.net Greg Stewart
            Votes:
            2 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: