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

BsonRepresentation annotation to be used with generics Lists & Maps

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: POJO
    • None
    • 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?

      Motivation: JAVA-3677 Introduced the use of BsonRepresentation annotation in order to have clean PoJo. That was a nice improvement.

      The current annotation cannot be used however in List & Maps: i.e. is not possible to have something like this:

       

      List<@BsonRepresentation(BsonType.OBJECT_ID) String>  
      Map<@BsonRepresentation(BsonType.OBJECT_ID) String, MyPojo> 

       

       

      This is mainly because the current annotation target is the following 

       

      @Target({FIELD,METHOD}) 

       

      It would be nice to have also as target TYPE_USE (e.g. thishttps://javaee.github.io/javaee-spec/javadocs/index.html?javax/validation/constraints/package-summary.html annotation can be used in type arguments of List and Map.

       

      In the C# driver this support is available: we have the DictionaryRepresentationhttps://mongodb.github.io/mongo-csharp-driver/1.11/serialization/ annotation

       

       

       

            Assignee:
            Unassigned Unassigned
            Reporter:
            asanti@leanitconsulting.ch Andrea Santi
            Votes:
            7 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: