Hi,
Suppose I have three tables: Report{id, ...}, Item{id, report_id, currency_code, ...} and Currency{code, name} and three mapped classes, with the same names. Item stores only the currency code. In order to provide a currency name in the Item class, we can use a Formula:
Code:
class Item {
@Formula("select name from Currency where code = CURRENCY_CODE")
private String currencyName;
...
}
A Report has many Items. Now suppose I need to filter the Item collection by currency name. Something like this:
Code:
@FilterDef(name="currencyNameFilter", parameters=@ParamDef(name="name", type="string"))
class Report {
@Filter(name="currencyNameFilter", condition="currencyName = :name")
private Set<Item> items;
...
}
Except that the filter above won't work, since the condition uses "currencyName", which is a
class field name. As far as I know, only
column names can be used inside a filter condition. But I can't use a column name because currencyName is a calculated field and does not have a corresponding column in the Item table. So the question is: is it possible to use a filter for formula-generated fields?