>I just want to double check, that I understand it correctly :
>
>Currently parser be able to parse only query against one object. ;-(
I think so.
>The problem is not the parser, the problem is nature of OQL language, it's
>OBJECT query language, so as result it return list of single Object Result
>Set, not a JOIN
>of different tables like SQL.
>So it would be hard to map SQL JOIN result to
>JDO.
>I guess, this is source of the problem. Please, let me know if I'm wrong.
Seem to me that it is because SQL always has only one level.
In SQL, if alias is not used, result works as a single alias are used.
So,
SELECT * FROM Employee e WHERE e.startDate=? AND e.age>?
is the same as
SELECT * FROM Employee WHERE Employee.startDate=? AND Employee.age>?
In OQL, you have multiple levels, so much more combination can happen, and
you got to be more specific.
SELECT e FROM Employee e,
WHERE ( e.address.state ='CA' AND e.address.city ='San Jose' )
If each employee has only one address, there is no confusion. So, the query
should consider as valid.
However, if address is in a one-to-many relationship with e, then you got to
specify which address's state and which address's city you're interested.
It seem that problem solve if we always assume e.address the same address.
However, consider the following query,
SELECT e FROM Employee e,
WHERE ( e.address.state='CA' AND e.address.state='OR' )
In this case, user might actually expecting the query to return an employee
who have two addresses, one in state CA, another in state OR.
Human might pretty easily distinguishes between two cases by the context.
However, both queries are ambiguous to the parser. As a result, an alias for
each one-to-many is required.
Anyway it is just the theory. There are still works to be done to the
parser...
Thomas
>
>Date: Tue, 18 Sep 2001 15:43:15 -0700
>From: "Thomas Yip" <[EMAIL PROTECTED]>
>Subject: RE: [castor-dev] OQL to SQL translation ...
>>Hi Illya,
>>
>>
>>
>> In theory, the parser generated the right SQL.
>>
>> The OQL you want should actually look like that:
>>
>> SELECT st FROM StudySeriesOnly st, st.series ser
>> WHERE st.studyID = $1 AND
> > ( ser.seriesModality = $2 AND ser.seriesNumer = $ 3 )
>>
>>However, the current implementation of the parser probably does not able
to
>>take the right OQL.
>>
>>
>>
>>Thomas
>
>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>Sent: Friday, September 14, 2001 2:32 PM
>>To: [EMAIL PROTECTED]
>>Subject: [castor-dev] OQL to SQL translation ...
>>
>>From: Ilya V Lipkind
>>
>>I have two objects with 1-n relationship : Study has list of series.
>>For OQL query like :
>> SELECT st FROM clinicaldb.StudySeriesOnly st WHERE studyID = $1 AND
>> (st.series.seriesModality = $2 AND
>> st.series.seriesNumber = $3)
>>
>>
>>got translated to SQL like :
>>
>>SELECT "STUDY".*, "GENRAL_SERIES".*
>>FROM "GENERAL_SERIES" "GENERAL_SERIES_1",
>> "GENERAL_SERIES" "GENERAL_SERIES_0",
>> "GENERAL_SERIES","STUDY"
>>WHERE "STUDY"."SID"="GENERAL_SERIES"."STUDY_SID"(+) AND
>> "STUDY"."SID"="GENERAL_SERIES_0"."STUDY_SID" AND
>> "STUDY"."SID"="GENERAL_SERIES_1"."STUDY_SID" AND
>> ("STUDY"."STUDY_ID" = '13313' AND
>> "GENERAL_SERIES_0"."MODALITY" = 'CT' AND
>> "GENERAL_SERIES_1"."SERIES_NUMBER" = 2)
>>FOR UPDATE
>>
>>Please, note, that there is two aliases for a child object. So , this
query
>>mean in plain English : "Give me all the studies with relevant series,
>>where study ID is 13313 and at least one series modality is CT OR series
>>number equal to 2. Basically, it return union of related studies.
>>
>>My expectation for SQL was different :
>>
>>SELECT "STUDY".*, "GENRAL_SERIES".*
>>FROM "GENERAL_SERIES","STUDY"
>>WHERE "STUDY"."SID"="GENERAL_SERIES"."STUDY_SID"(+) AND
>> ("STUDY"."STUDY_ID" = '13313' AND
>> "GENERAL_SERIES"."MODALITY" = 'CT' AND
>> "GENERAL_SERIES"."SERIES_NUMBER" = 2)
>>FOR UPDATE
>>
>>This query will return intersection of requested data and not a union. Any
>>help and experience, how can I specify the query on the child object of
1-n
>>relationship would be highly appreciate.
>>Also, if somebody can post list of OQL queries against objects, that have
>>different relationships. It's hard to define the queries only based on a
>>grammar and hope, that parser will accept it.
>>
>>Ilya.
>>
>>-----------------------------------------------------------
>>If you wish to unsubscribe from this mailing, send mail to
>>[EMAIL PROTECTED] with a subject of:
>> unsubscribe castor-dev
>>
>
>-----------------------------------------------------------
>If you wish to unsubscribe from this mailing, send mail to
>[EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev