【发布时间】:2013-08-10 11:01:58
【问题描述】:
是否可以使用 hql 只加入第一行(或任何其他行,但只有一个)?
select
config.id, mg.modelGroupName, min(deliveryType.id)
from
NotificationConfig config, NotificationConfigEntry configEntry, SettlementModelGroup mg
join
configEntry.notificationConfigEntryPK.user user
join
configEntry.notificationConfigEntryPK.deliveryType deliveryType
join
config.notificationType notifType
join
notifType.objectType objectType
where
config.id = configEntry.notificationConfigEntryPK.notificationConfig.id
and ( mg.modelId = config.objectId or config.objectId is null )
当然,这是我现在拥有的代码
min(deliveryType.id)
不起作用。 mg.modelId 和 config.objectId 之间没有映射关系,deliveryType 是一个列表。我不能使用不同的原因,因为我需要能够按 deliveryType(这没有任何意义,但无论如何我都需要这样做)和 modelGroupName 来订购。
【问题讨论】: