我需要将以下本机Query转换为等效的JQL
<named-native-query name="proffering">
<query>
<![CDATA[
SELECT po.OFFER_NAME, po.status, pov.effective_from, pov.effective_to, pov.sales_start_date, pov.sale_end_date,
pl.product_line_name, pl.product_line_id
FROM offerTable po, offerVersion pov, offerProdLine pl,
(SELECT po.offer_id, po.business_key business_key, MAX(VERSION_ID) MAX_VERSION
FROM offerTable po, offerVersion pov
WHERE po.offer_id = pov.offer_id
AND (po.OFFER_NAME = ?1 OR ?1 IS NULL)
AND (pov.PROD_LINE_ID = ?2 OR ?2 IS NULL )
AND (?3 >= pov.sales_start_date)
AND (?3 <= pov.sale_end_date OR pov.sale_end_date IS NULL )
GROUP BY ( po.offer_id, po.business_key ) ) view1
WHERE po.BUSINESS_KEY = view1.BUSINESS_KEY
AND pov.VERSION_ID = view1.MAX_VERSION
AND po.OFFER_ID = pov.OFFER_ID
AND pov.PROD_LINE_ID = pl.offerProdLine_ID
]]>
</query>
</named-native-query>
转换JPQL:
SELECT NEW
com.EntitySummary(
po.name, po.status,
pov.effectiveFromDate, pov.effectiveToDate, pov.salesAvailabalityStartDate, pov.salesAvailabalityEndDate,
pl.name, pl.prodLineId)
FROM
(SELECT po1.id, po1.businessKey businessKey, max(pov1.versionId) MAX_VERSION
FROM pov1.prodOffer po1, ProductOfferingVersion pov1
WHERE (po1.name = ?1 or ?1 is null)
AND (pov1.productLine.prodLineId = ?2 or ?2 is null)
AND (?3 >= pov1.salesAvailabalityStartDate)
AND (?3 <= pov1.salesAvailabalityEndDate OR ?3 IS NULL)
GROUP BY (po1.id, po1.businessKey)) view1
INNER JOIN ProductOfferingVersion pov on pov.versionId = view1.MAX_VERSION
INNER JOIN pov.prodOffer po on po.businessKey = view1.businessKey
INNER JOIN pov.productLine pl
但是,当我在jboss-eap-6.2中部署耳朵时,它拒绝了 识别“max”并抱怨意外的令牌'('