动态属性不会保存在数据库中,因此您无法使用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报告的属性,而他们是动态属性? –