Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
chengbinTechnology opened this issue Mar 24, 2022 · 2 comments
Open

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

chengbinTechnology opened this issue Mar 24, 2022 · 2 comments

Comments

@chengbinTechnology
Copy link

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

@chengbinTechnology
Copy link
Author

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
}

@chengbinTechnology
Copy link
Author

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":[{}]}]}]}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant