6

hqlを使用して最初の行のみ(または1つだけの他の行)を結合することは可能ですか?

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 で注文できるようにする必要がある明確な理由を使用できません。

4

1 に答える 1