動態屬性不會保存在數據庫中,因此您無法使用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中的模型中獲取動態值,並使用參數映射將其傳遞給您的碧玉報告。
非常感謝你。 –
那麼,我怎樣才能獲得Jasper報告的屬性,而他們是動態屬性? –