Hi All,

 

We are using OJB 0.9.8 and we are trying to use only ODMG API to access objects. We 
ran into problem with OJB OQL implementation: Suppose we have Rectangle object with 
'height' and 'width' properties and we want to load squares, in other words objects 
which have same values in both fields. To do so we write following code fragment:

 

OQLQuery query = odmg.newOQLQuery();

query.create("select rect from " + Rectangle.class.getName() +

                             " where width=height");

 

DList cmpAds = (DList) query.execute();

 

After OQL query executing we got all Rectangles and warning line "1: unexpected token: 
height" on console.

 

After analyzing oql-ojb.g grammar file we found that our expression is translated into 
Criteria.addEqualTo("width", "height") function call, which recognizes second argument 
as literal value and this causes incorrect OJB behaviour. We made some researches and 
found that our equal expression (width=height) has to be transformed in call of 
Criteria.addEqualToField("width", "height") method which creates criteria to compare a 
field to another field, but none of OQL statements transformed into addEqualToField 
function call.

 

Does it mean that there is impossible to execute above described query using OQL? Is 
there any other way in ODMG API for the same purpose?

 

Thanks,

Nick

Reply via email to