0

For the following entity mapping with Spring Data and Mongo DB :

@Document(collection = "candidates")
public class Candidate {
   private SortedMap<String, ? extends SortedMap<String, List<Expertise>>> expertises;
   ....
}

When loading the entity from the database the List< Expertise> becomes List< LinkedHashMap>. How can I specify the correct type of the object in the list?

1 Answer 1

2

That is a bug in our type resolution algorithm. We resolved the map value type of the outer map to Object, which drops all further generics information and thus no type information got written to the nested documents. This will cause only Maps being created on the reading side.

I've filed DATACMNS-440 for that and fixed it right away. The fix will be transitively included in the upcoming bugfix release (Spring Data MongoDB 1.3.4) early next week.

Still, I'd suggest you create dedicated types for the nested data structure as clients will have a hard time really knowing what this structure actually represents.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.