hi denis,

this is a known problem. ojb cannot properly handle multiple columns in a selection-criteria.

see http://nagoya.apache.org/scarab/issues/id/OJB242

i admit in your case it's only one column but the expression may be too complicated for SqlHelper#splitPath().

hth
jakob

[EMAIL PROTECTED] wrote:

I have an Equipment class, with a unitYear attribute, which is stored in the database as a decimal field (e.g. 1994, 1995, 2004).
My repository descriptor for the Equipment class is:
<class-descriptor
class="ca.richer.domain.Equipment"
table="FDAAREP"


    <field-descriptor
        name="unitNumber"
        column="AAACNB"
        jdbc-type="VARCHAR"
        primarykey="true"
    >
    </field-descriptor>
    <field-descriptor
        name="unitYear"
        column="AAADNB"
        jdbc-type="DECIMAL"
    >
    </field-descriptor>
</class-descriptor>

I'd like to select all Equipment instances that are at least a certain age. My OJB code is:
Criteria criteria = new Criteria();
criteria.addGreaterOrEqualThan("(year(current_date) - unitYear)", 5);


QueryByCriteria query = new QueryByCriteria(Equipment.class, criteria);

but this doesn't work ... it tells me that column unitYear is not an in the specified tables. However, the following code *does* work:
Criteria criteria = new Criteria();
criteria.addGreaterOrEqualThan("(year(current_date) - AAADNB)", 5);


QueryByCriteria query = new QueryByCriteria(Equipment.class, criteria);

and so does this (albeit with the wrong results, but it proves that unitYear is mapped properly):
Criteria criteria = new Criteria();
criteria.addGreaterOrEqualThan("unitYear", 5);


QueryByCriteria query = new QueryByCriteria(Equipment.class, criteria);

Is there some other way of doing this? Why doesn't OJB resolve unitYear to its column name?

Thanks,
Phil

--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to