【发布时间】:2020-01-09 14:27:17
【问题描述】:
我正在研究 Spring Boot 和 Hibernate 以及 我需要来自 mysql 数据库中不同表的数据,所以我运行自定义查询以从不同表中获取数据。我的查询是,
@Query(value = "Select i.item_id,i.item_name,s.size_name,sp.Prices from mt_item i join mt_sizeprice sp on i.item_id= sp.item_id join mt_size s on sp.size_id=s.size_id where i.merchant_fk= ?1 and is_featured=1",nativeQuery = true)
List<Object> get(long merchantId);
查询的结果是,
由于数据来自不同的表,我无法将 Object 的数据列表映射到我的模型类的列表中,
List<Object> get(long merchantId); to
List<FavoriteItem> list = new ArrayList<>();
【问题讨论】:
标签: java mysql hibernate spring-boot