Hi Michael,
Do you simply want all vehicles (?) with vehicleEquipments.code 580 or U11 ?
If so, I'd do
<snippet>
criteria1.addEqualTo("vehicleEquipments.code", "580");
criteria1.setAlias("EQUIPEMNT1");
criteria2.addEqualTo("vehicleEquipments.code", "U11");
criteria2.setAlias("EQUIPEMNT2");
criteriaTmp = new Criteria();
criteriaTmp.addOr(criteria1);
criteriaTmp.addOr(criteria2);
criteria3.addAndCriteria(criteriaTmp);
</snippet>
or, for more brevity, use an "in" criteria as in
<snippet>
List codes = new ArrayList();
codes.add("580");
codes.add("U11");
criteria3.addIn("vehicleEquipments.code", codes);
</snippet>
Looking at your extract of code, and your extract from the spy log, OJB
seems to be doing exactly what you've asked it to.
Cheers,
Charles
>-----Original Message-----
>From: Michael Schulze [mailto:[EMAIL PROTECTED]
>Sent: 16 June 2003 15:43
>To: OJB Users List
>Subject: Problem with Criteria and Alias
>
>
>Hello List,
>
>I have a problem with a PB query and aliases for joined tables. I build
>a criteria like this to join the vehicle table with the equipment table
>twice:
>
>criteria1.addEqualTo("vehicleEquipments.code", "580");
>criteria1.setAlias("EQUIPEMNT1");
>
>criteria2.addEqualTo("vehicleEquipments.code", "U11");
>criteria2.setAlias("EQUIPEMNT2");
>
>criteria3.addAndCriteria(criteria1);
>criteria3.addAndCriteria(criteria2);
>
>the resulting query fails because of the assigned aliases of the joined
>equipment tables. From the p6spy log:
>
>SELECT A0.VEHI_RELEASE_TS, ...
>
>FROM (V0QRVEHI A0 INNER JOIN V0QRVEEQ A1 ON
>A0.VEHI_KEY=A1.VEEQ_VEHI_KEY)
>INNER JOIN V0QRVEEQ A2 ON A0.VEHI_KEY=A2.VEEQ_VEHI_KEY
>
>WHERE ( A3.VEEQ_CODE = '580' ) AND (A2.VEEQ_CODE = 'U11' )
>
>the FROM clause uses A1 and A2 as aliases for the equipment
>tables where
>as the JOIN clause uses A2 and A3. It works fine if i don't assign an
>alias to criteria1.
>
>Is there anything i do wrong or is this a bug in OJB?
>
>I use 1.0 rc3 with jdk 1.4.1.
>
>Thanks,
>Michael
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
This email and any attachments are strictly confidential and are intended
solely for the addressee. If you are not the intended recipient you must
not disclose, forward, copy or take any action in reliance on this message
or its attachments. If you have received this email in error please notify
the sender as soon as possible and delete it from your computer systems.
Any views or opinions presented are solely those of the author and do not
necessarily reflect those of HPD Software Limited or its affiliates.
At present the integrity of email across the internet cannot be guaranteed
and messages sent via this medium are potentially at risk. All liability
is excluded to the extent permitted by law for any claims arising as a re-
sult of the use of this medium to transmit information by or to
HPD Software Limited or its affiliates.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]