java list(用于将bo对象转换为数据库对象)

时间:2018-01-03 09:16:41

标签: hibernate

我收到错误,因为类型不匹配无法在下面的代码中从void转换为list ..请帮我解决一下?

public static List<roleBO> convertBOTODOCreateRolebo(List<roleDO> role) 
{
   java.lang.reflect.Type targetListType = new TypeToken<List<roleBO>>() {}.getType();
   List<roleBO> roleboss =new ModelMapper().map(role, targetListType);
   return roleboss;
}

1 个答案:

答案 0 :(得分:0)

将功能更改为:

public static List<roleBO> convertBOTODOCreateRolebo(List<roleDO> role) 
{
    List<roleBO> roleboss = role.stream().
        map(i -> mapRole(i)).collect(Collectors.toList());
    return roleboss;
}

在同一个类中创建函数:

private static roleBO mapRole(roleDO role) {
    roleBO result = new roleBO();
    // here set properties of result object from properties of role object
    return result;
}