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

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Unknown Unknown
    • None
    • None
    • POJO
    • None

    Description

      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.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            contact@gjstewart.net Greg Stewart
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: