While this workaround works for a map to add "by hand" in mongodb the key "_class" and the value "java.util.HashMap". For an array it isn't possible.
The mapper don't even recognize the array structure of the json "[ ]". It should map it automatically to an ArrayList, without any problem.
Indeed in such a scenario :
A.getValue() is only an unreadable Object!!!Code:final ArrayList<String> list = new ArrayList<String>(); list.add("foobar"); A<ArrayList<String>> a = new A<ArrayList<String>> (list); mongoTemplate.save(a, "test"); final List<A> findAll = mongoTemplate.findAll(A.class, "test");
even if the mongo json result is :
If the query is mapped on a BasicDBObject, the array is well recognized as a BasicDBList... so I don't understand why it is not mapped on an ArrayList.Code:{ "_id" : ObjectId("4ef1f49dc46a3d6b2d9269ef"), "_class" : "foo.bar.A", "valueType" : "java.util.ArrayList", "value" : [ "foobar" ] }
Thanks for any help!


Reply With Quote
