[JAVA-3408] TypeParameters for nested types are not properly collected Created: 27/Aug/19  Updated: 28/Oct/23  Resolved: 04/May/21

Status: Closed
Project: Java Driver
Component/s: POJO
Affects Version/s: None
Fix Version/s: 4.0.0

Type: Bug Priority: Minor - P4
Reporter: Ross Lawley Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Case:

 Description   

public class A<T> {
    private List<List<T>> values;
}
 
public class B extends A<Float>{
    @BsonId
    private Integer id;
}

The type for values is not correctly captured and results in the codec registry looking for a handler for List<List<Object>> and not List<List<Float>>.



 Comments   
Comment by Ross Lawley [ 04/May/21 ]

Cherry pick to 3.12.x - https://github.com/mongodb/mongo-java-driver/pull/704

Comment by Githook User [ 03/Feb/20 ]

Author:

{'name': 'Ross Lawley', 'username': 'rozza', 'email': 'ross.lawley@gmail.com'}

Message: PojoCodec: Fix mapping for nested generic types

JAVA-3408
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/a4e0a536d9c3572d52120172f02ff3051a407767

Comment by Ross Lawley [ 24/Jan/20 ]

PR: https://github.com/rozza/mongo-java-driver/pull/354

Comment by Justin Lee [ 27/Aug/19 ]

In Morphia how I (mostly) support this is to treat those parameter types as Objects.  Then I have an ObjectCodec that will set a bookmark and scan for the discriminator value.  Having that, it can do a registry lookup for the correct codec and then delegate.

Generated at Thu Feb 08 08:59:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.