0

我有一个用于订单和项目的自定义模型,它将包含比实际实体类最少的数据

楷模

class OrderMinimalModel {    
    long id;    
    String comment;    
    List<ItemMinimalModel> items;
}

class ItemMinimalModel{    
    long id;    
    String name;
}

我正在寻找的查询

@Query( value = "SELECT O.id as orderId, O.comment as orderComment, I.id as itemId, I.name as itemName FROM order O "
        + " left join item I on I.order_id = O.id"
        + " WHERE O.status = 1 ",nativeQuery = true)
List<OrderMinimalModel > findAllOrderMinimal();

但我收到以下错误

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [org.springframework.data.jpa.repository.query.AbstractJpaQuery$TupleConverter$TupleBackedMap] to type [com.example.model.OrderMinimalModel]

也许我做错了。

4

0 回答 0