2017-05-26 42 views
1

例如:如何在Hybris Jasper報告中使用Flexible Search搜索字段類型=「動態」?

SELECT 
{adjustment.pk}, 
{reason.code}, 
{reason.description}, 
{adjustment.orderNumber} 
{adjustment.creator}, 
{cs.agentID}, 
{cs.mobilePhone} 
    FROM {OrderValueAdjustment as adjustment JOIN AdjustOrderReason AS reason ON {adjustment.reason} = {reason.pk} 
    JOIN CsEmployee AS cs ON {adjustment.creator} = {cs.pk} 
    } 
WHERE {adjustment.pk} = 8796093131124 

擲假因爲{adjustment.orderNumber}是動態的屬性類型。

回答

2

動態屬性不是持久屬性,因此無法使用靈活查詢進行搜索。

+0

非常感謝你。 –

+0

那麼,我怎樣才能獲得Jasper報告的屬性,而他們是動態屬性? –

0

動態屬性不會保存在數據庫中,因此您無法使用FLexible Search獲取它們。

爲了解決尤爾碧玉報告的問題,如果你看一個JRXML文件(salesByCountry.jrxml例如)接近,你會看到這部分:

<queryString> 
      <![CDATA[SELECT x.COUNTRY AS COUNTRY, SUM(x.TOTPRICE) as TOTPRICE 
FROM 
({{ 
Select {country.name} as COUNTRY, COALESCE(sum({o.totalPrice} * {c2.conversion}/{c.conversion}),0) as TOTPRICE 
from { Country AS country LEFT JOIN Address AS a ON {a.country}={country.PK} LEFT JOIN Order AS o ON {o.paymentAddress}={a.PK} LEFT JOIN Currency as c ON {o.currency}={c.PK} LEFT JOIN Currency as c2 ON {c2.pk}= $P{Currency} AND {o.creationtime} >= $P{From} AND {o.creationtime} < $P{To}} 
GROUP BY {country.PK}, country 
}} 
UNION ALL 
{{ 
Select {country.name} as COUNTRY, COALESCE(sum({o.totalPrice} * {c2.conversion}/{c.conversion}),0) as TOTPRICE 
from { Country AS country LEFT JOIN Address AS a ON {a.country}={country.PK} LEFT JOIN Order AS o ON {o.paymentAddress}={a.PK} LEFT JOIN Currency as c ON {o.currency}={c.PK} LEFT JOIN Currency as c2 ON {c2.pk}= $P{Currency} AND {o.creationtime} >= $P{From} AND {o.creationtime} < $P{To} AND {o.paymentAddress} IS NULL} 
GROUP BY {country.PK}, country 
}}) x 
GROUP BY COUNTRY 
ORDER BY TOTPRICE DESC]]> 
     </queryString> 

你可以做的是替換數據使用這個靈活的搜索參數(作爲jrxml中的貨幣)進行檢索。然後,您只需從java中的模型中獲取動態值,並使用參數映射將其傳遞給您的碧玉報告。