【发布时间】:2018-06-20 01:39:50
【问题描述】:
我有品牌类,它与规范类MobileBrands.class 一对一映射:
private int id;
private String name;
private int price;
@OneToOne
private MobileSpecification prodInfo;
MobileSpecification.class:
private int id;
private String ram;
private String rom;
@OneToOne
private MobileBrands brands;
我知道 sql 可以正常工作。
SQL:
select mobile_brands.id, mobile_brands.name, specification.ram, specification.rom
from mobile_brands inner join specification on
mobile_brands.brand_id=specification.ID where mobile_brands.BRAND_ID='1'
虽然我是 HQL 查询的新手,但我已经尝试过:
SELECT u.id as id, u.name as name,
u.prodInfo.ram as ram, u.prodInfo.rom as rom from MobileBrands inner join MobileSpecification
with MobileBrands.id=MobileSpecification.id where MobileBrands.id='1'"
哪个不起作用(HQL 之一)。怎么转成HQL?
【问题讨论】: