Hi Doug,
Thanks for your useful information given which clarified many doubts of mine and my misunderstandings on Ejb QL.
Karthik
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 AM 12:15
To: [EMAIL PROTECTED]
Subject: Re: EJBQL and SQL
>Hi Evan,
> Thanks for your reply.
> Since its a one to one relation, the ejbql will be something like
>this.
> select object(c) from Customer c, Address a where a.iD=?1;
> Please check the following SQL code generated by j2ee;
> Select c.name from Customer c, Address A where a.iD=?
> How abt the sql generated by other app servers for the above ejbql?
If you want the address listed to be the customer's address (for a one-to-one relationship), the best way to represent this in EJB-QL is:
select object(c) from Customer c where c.address.ID = ?1;
The syntax above shows how EJB-QL makes it very easy and convenient to traverse container managed relationships (CMRs) in a query, as explicitly performing the join is not required.
If you instead say:
select object(c) from Customer c, Address a where a.ID = ?1;
Here, the address is NOT explicitly linked to the customer and can represent any address in the database, which is most likely NOT the desired result.
Doug
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error please notify the
originator of the message.
Any views expressed in this message are those of the individual
sender, except where the sender specifies and with authority,
states them to be the views of Huawei Technologies India Pvt. Ltd.
