【发布时间】:2009-11-04 07:48:54
【问题描述】:
我有三个表和 2 个 JPA 模型类:
Unit
------------
id [PK] - Integer
code - String
unitGroups - List<UnitGroup>
UnitGroup
------------
id [PK] - Integer
ugKey - String
units - List<Unit>
units 和 unitGroups 之间有多对多的关系。 简要地说,我想编写一个 HQL 查询来获取以下 sql 的输出:
SELECT u.*
FROM units u, unit_groups ug, unit_group_pairs ugp
WHERE ugp.UnitID = u.ID
AND ugp.UnitGroupID = ug.ID
AND ug.UGKey = 'amount' AND u.ID = 10
【问题讨论】: