You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Raymond Barlow <rb...@raymanoz.com> on 2004/02/17 23:23:44 UTC

criteria on calculated columns

Hi guys,

I have an object that is persisted, but not all of the columns exist in 
the database. Some of the columns are calculated in the object and are 
read only. As an example, lets say that the object is a Period object 
with 3 fields: dateFrom, dateTo and totalDays. totalDays here can be 
calculated as dateTo-dateFrom (or some other business logic).

Is it possible to use OJB's QueryByCriteria to retreive where (for 
example) totalDays < 10? If so, how?

-- 
Regards,
Raymond Barlow




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: criteria on calculated columns

Posted by Raymond Barlow <rb...@raymanoz.com>.
Thanks for the reponse Jakob. Now, at least, I know I was doing things 
the right way!

-Raymond

Jakob Braeuchi wrote:

> hi raymond,
>
> the short answer is 'NO'. ojb does not know that totalDays can be 
> calculated.
> you could try to use Criteria#addSql() but then you have to specify 
> the column names not the attribute names.
>
> jakob
>
> Raymond Barlow wrote:
>
>> Hi guys,
>>
>> I have an object that is persisted, but not all of the columns exist 
>> in the database. Some of the columns are calculated in the object and 
>> are read only. As an example, lets say that the object is a Period 
>> object with 3 fields: dateFrom, dateTo and totalDays. totalDays here 
>> can be calculated as dateTo-dateFrom (or some other business logic).
>>
>> Is it possible to use OJB's QueryByCriteria to retreive where (for 
>> example) totalDays < 10? If so, how?
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>

-- 
Regards,
Raymond Barlow




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


Re: criteria on calculated columns

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi raymond,

the short answer is 'NO'. ojb does not know that totalDays can be calculated.
you could try to use Criteria#addSql() but then you have to specify the column 
names not the attribute names.

jakob

Raymond Barlow wrote:

> Hi guys,
> 
> I have an object that is persisted, but not all of the columns exist in 
> the database. Some of the columns are calculated in the object and are 
> read only. As an example, lets say that the object is a Period object 
> with 3 fields: dateFrom, dateTo and totalDays. totalDays here can be 
> calculated as dateTo-dateFrom (or some other business logic).
> 
> Is it possible to use OJB's QueryByCriteria to retreive where (for 
> example) totalDays < 10? If so, how?
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org