在Oracle CCB Utilities框架中使用SELECT子句时的HQL查询异常

时间:2015-09-21 13:18:24

标签: hibernate

我在hql(Oracle CC& B Utilities Framework)中遇到了问题

我的SQL查询是

select msg.EXT_MSG_ID, msg.MKTMSG_ID
from  O2_IN_CA_MSG msg
where EXT_MSG_ID = (select to_char(max(to_number(msg1.EXT_MSG_ID)))
                          from O2_IN_CA_MSG msg1, F1_BUS_OBJ_STATUS bostatus 
                          where msg1.BUS_OBJ_CD = bostatus.BUS_OBJ_CD 
                                AND bostatus.BO_STATUS_COND_FLG <> 'F1FL' 
                                AND msg1.BO_STATUS_CD = bostatus.BO_STATUS_CD 
                                AND msg1.BUS_OBJ_CD = 'O2-OESPCusTarIn'
                                AND msg1.SRC_DOC_ID = '12345678' 
                                AND msg1.MKTMSG_ID <> '179977027857'
                                AND msg1.acct_id = '7565333022'
                  )

HQL Query1:

FROM InboundCustomerAdminMessage inboundCustomerAdminMessage
WHERE inboundCustomerAdminMessage.externalMessageId = 
    (TO_CHAR(MAX(TO_NUMBER(inboundCustomerAdminMessage1.externalMessageId))) 
    FROM InboundCustomerAdminMessage inboundCustomerAdminMessage1, BusinessObjectStatus businessObjectStatus 
    WHERE inboundCustomerAdminMessage1.businessObject.id = businessObjectStatus.id.businessObject.id 
    AND businessObjectStatus.condition <> :boStatusCond 
    AND inboundCustomerAdminMessage1.status = businessObjectStatus.id.status 
    AND businessObjectStatus.id.businessObject.id = :businessObjectId 
    AND inboundCustomerAdminMessage1.sourceDocumentId = :srcDocId 
    AND inboundCustomerAdminMessage1.id <> :mktMsgId )

例外是:ORA-00934:此处不允许使用组功能

我尝试使用SELECT进行第二次查询 HQL查询2:

FROM InboundCustomerAdminMessage inboundCustomerAdminMessage
WHERE inboundCustomerAdminMessage.externalMessageId = 
    (SELECT TO_CHAR(MAX(TO_NUMBER(inboundCustomerAdminMessage1.externalMessageId))) 
    FROM InboundCustomerAdminMessage inboundCustomerAdminMessage1, BusinessObjectStatus businessObjectStatus 
    WHERE inboundCustomerAdminMessage1.businessObject.id = businessObjectStatus.id.businessObject.id 
    AND businessObjectStatus.condition <> :boStatusCond 
    AND inboundCustomerAdminMessage1.status = businessObjectStatus.id.status 
    AND businessObjectStatus.id.businessObject.id = :businessObjectId 
    AND inboundCustomerAdminMessage1.sourceDocumentId = :srcDocId 
    AND inboundCustomerAdminMessage1.id <> :mktMsgId )

这次除外是: 创建hibernate查询'FROM InboundCustomerAdminMessage inboundCustomerAdminMessage WHERE inboundCustomerAdminMessage.externalMessageId = all (select TO_CHAR(MAX(TO_NUMBER(inboundCustomerAdminMessage1.externalMessageId))) FROM InboundCustomerAdminMessage inboundCustomerAdminMessage1, BusinessObjectStatus businessObjectStatus WHERE inboundCustomerAdminMessage1.businessObject.id = businessObjectStatus.id.businessObject.id AND businessObjectStatus.condition <> :boStatusCond AND inboundCustomerAdminMessage1.status = businessObjectStatus.id.status AND businessObjectStatus.id.businessObject.id = :businessObjectId AND inboundCustomerAdminMessage1.sourceDocumentId = :srcDocId AND inboundCustomerAdminMessage1.id <> :mktMsgId ) '

时出错

org.hibernate.QueryException:(之前预期)在select [select inboundCustomerAdminMessage.externalMessageId FROM com.splwg.domain.mtm.inbound.inboundCustomerAdminMessage.InboundCustomerAdminMessage__ inboundCustomerAdminMessage WHERE inboundCustomerAdminMessage.externalMessageId = all(select TO_CHAR(MAX(TO_NUMBER(inboundCustomerAdminMessage1.externalMessageId)))FROM com.splwg.domain.mtm.inbound.inboundCustomerAdminMessage.InboundCustomerAdminMessage__ inboundCustomerAdminMessage1,com.splwg.domain.common.businessObject.BusinessObjectStatus__ businessObjectStatus WHERE inboundCustomerAdminMessage1.businessObject.id = businessObjectStatus.id .businessObject.id AND businessObjectStatus.condition&LT;&GT;:boStatusCond AND inboundCustomerAdminMessage1.status = businessObjectStatus.id.status AND businessObjectStatus.id.businessObject.id =:businessObjectId AND inboundCustomerAdminMessage1.sourceDocumentId =:srcDocId AND inboundCustomerAdminMessage1.id&LT ;&GT; :mktMsgId)inboundCustomerAdminMessage.externalMessageId desc]

请你帮助任何人如何在hql中使用SELECT子句。

1 个答案:

答案 0 :(得分:0)

在HQL中删除“inboundCustomerAdminMessage.externalMessageId desc”的顺序