Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / October 2003

Tip: Looking for answers? Try searching our database.

urgent! pls help! some questions about EJB QL

Thread view: 
maggie2003 - 26 Sep 2003 04:57 GMT
Hello,

I'm new learner on EJB and now I'm working on a project which need to
do SQL to EJB QL translation. I went through the specification 2.0 of
EJB QL released by Sun, I'm not quite understand the following words
regarding to the SELECT clause of EJB QL:

"In the case of a find method, the SELECT clause is restricted to
contain either a single range variable or a single value path
expression that evaluates to the abstract schema type of the entity
bean for which the finder method is defined.
Because finder method cannot return arbitrary types, the SELECT clause
of an EJB QL defined for a finder method must always correspond to the
abstract shcema type fo the entity bean for which the finder method is
defined.In contrast, the SELECT clause of a query defined for a select
method can return the abstract schema types of other entity beans or
the values of cmp-fields."

As my understanding, I think the SELECT clause of finder method can
only contain a single range variable instead of single value path
expresson, it should have only one format, which is "SELECT [DISTINCT]
OBJECT(identification_variable)".

For example: the query below is defined in OrderBean
findByProductType();
SELECT OBJECT(o) FROM Order o, IN(o.lineItems) l
WHERE l.product.product_type = 'schoolsupplies'

how it could be a single value path expression , I think this format
can only be used in Select method.

Another question is, EJB QL 2.0 does not support subquery and EXIST,
does this mean that a SQL query with subquery or EXIST clause can't be
translated to EJB QL?

I don't know if I'm correct or not. I'd appreciate if anybody can help
me with this.

Thanks!
Maggie
Christopher Blunck - 22 Oct 2003 05:14 GMT
> Hello,
>
[quoted text clipped - 36 lines]
> Thanks!
> Maggie

Hi Maggie-

My background is with BEA WebLogic 7.0 and TopLink 9.0.3 CMP, so take
everything I say with a grain of salt because TopLink certainly has lots
of "features" that are not part of core J2EE, but it also does not
implement items that are supposed to exist in J2EE.  That being said, I
struggled with EJB QL syntax and had a hard time locating information on
the net, so I am very sympathetic to your situation and would like to
share the information I have.

What it looks like you are trying to do is to locate orders containing a
line item, which has a product who's product_type is 'schoolsupplies'.

Your EJB QL looks fine to me.  Does the finder not work properly?

As for your second question about subqueries and exist - you are correct.
Some SQL queries simply cannot be translated to EJB QL 2.0.  There are
several limitations in the current EJB QL spec (most notably the lack of
time support for comparisons (!!)) - they'll get better over time tho.

In the meantime, most vendors I believe offer some way of issuing SQL to
augment your EJB QL.  TopLink does.

-c


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.