In a POJO if you have a field or method that is marked with @BsonIgnore , and if this is a type disallowed by the TypeData$Builder the class model creation will fail - despite this field / method not being required.
Example exception
java.lang.IllegalStateException: Invalid Map type. Maps MUST have string keys, found class com.TestEnum instead.
at org.bson.codecs.pojo.TypeData$Builder.validate(TypeData.java:117)
at org.bson.codecs.pojo.TypeData$Builder.build(TypeData.java:104)
at org.bson.codecs.pojo.PojoBuilderHelper.getTypeData(PojoBuilderHelper.java:158)
at org.bson.codecs.pojo.PojoBuilderHelper.configureClassModelBuilder(PojoBuilderHelper.java:87)
at org.bson.codecs.pojo.ClassModelBuilder.<init>(ClassModelBuilder.java:59)
at org.bson.codecs.pojo.ClassModel.builder(ClassModel.java:63)
at org.bson.codecs.pojo.PojoCodecProvider.createClassModel(PojoCodecProvider.java:194)
at org.bson.codecs.pojo.PojoCodecProvider.access$100(PojoCodecProvider.java:38)
at org.bson.codecs.pojo.PojoCodecProvider$Builder.build(PojoCodecProvider.java:115)
Here the pojo contains a Map keyed on an enum. This map is marked with @BsonIgnore, hence I would not expect the failure above.
- is related to
-
JAVA-2653 POJO that implements a generic interface cannot be serialized
- Closed