orika-mapper/orika

bean has list<Map> can't do trans completed!

chengbinTechnology opened this issue · 2 comments

public class DataWrapper {

List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();

public DataWrapper(){
    Map<String,Object> map=new HashMap<String,Object>();
    map.put("dafa","ddd");
    map.put("daffa","mmmm");
    list.add(map);
}

public List<Map<String, Object>> getList() {
    return list;
}

public void setList(List<Map<String, Object>> list) {
    this.list = list;
}

}

public class ChengbinDescribe extends PersonSource {

private DataWrapper auths;


public DataWrapper getAuths() {
    return auths;
}

public void setAuths(DataWrapper auths) {
    this.auths = auths;
}

}

public class StudentSource {

private DataWrapper auths;

public DataWrapper getAuths() {
    return auths;
}

public void setAuths(DataWrapper auths) {
    this.auths = auths;
}

}

public static void main(String[] args) throws Exception{
ChengbinDescribe twoSource=new ChengbinDescribe();
InnerBean innerBean=new InnerBean();
DataWrapper wrapper=new DataWrapper();
List<Map<String,Object>> list=new ArrayList<Map<String,Object>>();
Map<String,Object> map=new HashMap<String,Object>();
map.put("chengbin","host");
map.put("cxt","hust");
list.add(map);
map=new HashMap<String,Object>();
map.put("keys","kust");
map.put("key2","kbst");
list.add(map);
wrapper.setList(list);
wrapper.getList().addAll(innerBean.buskMap());
twoSource.setAuths(wrapper);
// twoSource.setInnerBean(innerBean);
//twoSource.setInnerBean(innerBean);
//json Utils can do it
StudentSource studentSource2=EntityUtils.toBean(twoSource,StudentSource.class);
System.out.println(EntityUtils.toJson(twoSource));
StudentSource studentSource1=OrikaMapperUtils.transBean(twoSource,StudentSource.class);
//System.out.println(studentSource1.getUserMap());
System.out.println(studentSource2);
System.out.println(studentSource1.getAuths().getList());
System.out.println(EntityUtils.toJson(studentSource1));
}

{"auths":{"list":[{"chengbin":"host","cxt":"hust"},{"key2":"kbst","keys":"kust"},{"dafa":"ddd","daffa":"mmmm"}]}}
StudentSource@771a660
[{}, {}, {}]
{"auths":{"list":[{},{},{}]}}

jsonutils can't do it,but this is not can do it!

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by ma.glasnost.orika.converter.builtin.CloneableConverter (file:/D:/DevSourceDir/GradleLocalSource/caches/modules-2/files-2.1/ma.glasnost.orika/orika-core/1.5.4/b4f1019bfeda6d6aa0790a42f2d317151d2d2f4d/orika-core-1.5.4.jar) to method java.lang.Object.clone()
WARNING: Please consider reporting this to the maintainers of ma.glasnost.orika.converter.builtin.CloneableConverter
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

the application logging output this message:

Orika_LinkedHashMap_HashMap_Mapper24876062731500$2.mapAToB(HashMap<String, Object>, LinkedHashMap) {
Field(empty(boolean), empty(boolean)) : excluding because LinkedHashMap<String, Object>.empty(boolean) is not assignable and cannot be mapped in-place
}
Orika_LinkedHashMap_HashMap_Mapper24876062731500$2.mapBToA(LinkedHashMap<String, Object>, HashMap) {
Field(empty(boolean), empty(boolean)) : excluding because HashMap<String, Object>.empty(boolean) is not assignable and cannot be mapped in-place
}

jsonUtilsResult: {"auths":{"list":[{"name":"innerBean","innerMap":[{"keys":"asdfaf","must":"bbbb"}],"mostMap":[{"list":[{"whk":"22"}]}]},{"name":"innerBean","innerMap":[{"keys":"asdfaf","must":"bbbb"}],"mostMap":[{"list":[{"whk":"22"}]}]}]}}
[InnerBean@18df8434, InnerBean@65c7a252]
orikaUtilsResult: {"auths":{"list":[{"name":"innerBean","innerMap":[{}],"mostMap":[{"list":[{}]}]},{"name":"innerBean","innerMap":[{}],"mostMap":[{"list":[{}]}]}]}}