2013-08-08 22 views
5

hql kullanarak sadece ilk satırı (veya sadece herhangi bir satırı değil, yalnızca bir satırı) birleştirmek mümkün mü? HQL ile sadece ilk satırı birleştir

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) 

Bu

min(deliveryType.id) 

çalışmıyor tabii ki, şu anda ben yaşıyorum koddur. Mg.modelId ve config.objectId arasındaki ilişki eşlenmiyor ve deliveryType bir listedir. Farklı neden kullanamıyorum deliveryType ile sipariş verebilmem gerekiyor (bu bir anlam ifade etmeyecek, ama yine de yapmam gerekecek) ve modelGroupName.

cevap

0
 
select 
config.id, mg.modelGroupName, deliveryType.id 
from 
NotificationConfig config, NotificationConfigEntry configEntry, SettlementModelGroup mg 
join 
configEntry.notificationConfigEntryPK.user user 
join 
configEntry.notificationConfigEntryPK.deliveryType deliveryType with deliveryType.id = (select min(id) from configEntry.notificationConfigEntryPK.deliveryType) 
...