-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Filter for calculated fields
PostPosted: Tue Nov 24, 2009 2:32 pm 
Newbie

Joined: Mon Sep 21, 2009 9:40 am
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.