Tua*_*ham 6 hibernate join hql
是否可以使用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 )
Run Code Online (Sandbox Code Playgroud)
当然,这是我现在拥有的代码
min(deliveryType.id)
Run Code Online (Sandbox Code Playgroud)
不起作用.未映射mg.modelId和config.objectId之间的关系,deliveryType是一个列表.我不能使用不同的原因我需要能够通过deliveryType订购(这没有任何意义,但我还是需要它)和modelGroupName.
小智 1
选择 config.id、mg.modelGroupName、deliveryType.id 从 NotificationConfig 配置、NotificationConfigEntry configEntry、SettlementModelGroup mg 加入 configEntry.notificationConfigEntryPK.user 用户 加入 configEntry.notificationConfigEntryPK.deliveryType 传递类型 带有传递类型.id =(从 configEntry.notificationConfigEntryPK.deliveryType 中选择 min(id)) ...