[英]How can I convert a Composite ID stored in a MongoDB into a Morphia Java entity object?
[英]How can I convert Entity to Object in java
我定义了一个可以添加任何类型元素的常规List,定义为: List<List<Object>> rows = new ArrayList<>()
; 但是当我从服务层获取列表时,编译过程将引发不兼容的类型异常,代码示例如下:
List<List<Object>> rows = new ArrayList<>();
List<ProductEntity> result = searchResponse.getProducts();
rows.add(result);
例外是: incompatible types: java.util.List<com.shopee.data.webapispec.brandseller.entity.product.ProductEntity> cannot be converted to java.util.List<java.lang.Object>
运行命令时, incompatible types: java.util.List<com.shopee.data.webapispec.brandseller.entity.product.ProductEntity> cannot be converted to java.util.List<java.lang.Object>
“ mvn clean install
”,有人知道如何处理吗?
ProductEntity
是Object
的子类。 但是List<ProductEntity>
不是List<Object>
的子类。
您需要List<List<? extends Object>> rows = new ArrayList<>();
List<List<? extends Object>> rows = new ArrayList<>();
使这项工作。
有关泛型和对象层次结构的详细信息,请参见此处
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.