nutzam / nutzmongo

MongoDB 驱动的薄封装, 并入nutzmore项目,不再单独维护
https://nutz.cn
16 stars 15 forks source link

无法反序列化对象中的集合 #8

Closed fjay closed 7 years ago

fjay commented 7 years ago

实体类:

public class A {
    private String id;
    private List<B> bList= new ArrayList<>();

  //  省略get/set
}

public class B{

    private String name;
    private String path;

   //  省略get/set
}

ZMo.me().fromDocToObj(doc, A.class);

访问bList对象时报: java.lang.ClassCastException: com.mongodb.BasicDBObject cannot be cast to xxx.B

wendal commented 7 years ago

doc的内容是什么? toJson贴一下

fjay commented 7 years ago
{"dBobj":{"_id":{"counter":4857850,"date":"2017-03-28 15:48:22","machineIdentifier":1400323,"processIdentifier":20048,"time":1490687302000,"timeSecond":1490687302,"timestamp":1490687302},"bList":[{"path":"x","name":"a"}],"id":"fbbf257c-d9d0-4545-b1d4-f07024df9bf4"},"empty":false,"id":{"$ref":"$.dBobj._id"},"partialObject":false}
wendal commented 7 years ago

恩,大概知道什么问题了