Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Invalid EBJQL

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One of the test programs identified the following EBJQL query as invalid:
SELECT s.name FROM Student s, Program p where s.subjectid=p.subjectId
Can someone tell me what is wrong with it???
Much appeciated.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Keith
Do you come from a SQL background? I do, and I'm finding EJB-QL a bit tricky because of this. EJB-SQL doesn't seem to do joins explicitly, you have to use IN with a CMR field. On page 239 of the spec, it gives an example of some EJB-QL and the equivalent SQL:
SELECT OBJECT(o)
FROM Order o, IN(o.lineItems) l
WHERE l.quantity > 5
SELECT DISTINCT o.OKEY
FROM ORDERBEAN o, LINEITEM l
WHERE o.OKEY = l.FKEY AND l.QUANTITY > 5
Does this help at all? I'm new to EJB myself, so I might be barking up the wrong tree.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Colin, you are absolutely right.
Keith, you might want to also refer 'The J2EE Tutorial' book from Sun. I thing there is also free copy available online. This has good info on EJBQL.
p.s. the questions on EJB-QL are not so tricky. They are pretty straight-forward. Still wondering why I lost marks there.
I have few questions for Kathy
Please respond if possible...
Currently I am trying to convince my boss to use CMP Entity Bean. While studying our current system, I found some places, where we want to allow 'DYNAMIC QUERYING' . Say for example, a user selects the field and relational operators from screen and the query is generated. Currently EJB-QL does not support this . But the application service providers (BEA, IBM & Borland) had made a provision to run query dynamically. But then I discovered that one of our dynamic query has 'OUTER JOIN', again not supported by EJB-QL .
Was there any reason for omitting out these features?
When (If any) will these be introduced ?
(It took more than 27 months to go from EJB 2.0 to EJB 2.1)

Thanks.
Peter Vennel
SCJP,SCJD,SCWCD,SCBCD,IBM-XML,MCP.
[ February 05, 2004: Message edited by: Peter Vennel ]
[ February 05, 2004: Message edited by: Peter Vennel ]
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Colin Richardson:

SELECT OBJECT(o)
FROM Order o, IN(o.lineItems) l
WHERE l.quantity > 5
SELECT DISTINCT o.OKEY
FROM ORDERBEAN o, LINEITEM l
WHERE o.OKEY = l.FKEY AND l.QUANTITY > 5
Does this help at all? I'm new to EJB myself, so I might be barking up the wrong tree.


I too have the same question. Most of the EJB developers are familiar with SQL. Why did SUN deviate from the standard SQL coding style?.....

SELECT OBJECT(o)............this is OK for me, as it returns a list of local/remote interfaces that is not there in standard SQL but that strange syntax for IN Clause...
As for as the exam is concerned, I found the EJB-QL questions to be easy as long as you understand and appreciate this new syntax for IN Clause to perform a join between related entity beans.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The valid SQL expression:
SELECT s.name FROM Student s, Program p where s.subjectid=p.subjectId
could be presented in EJB-QL like:
SELECT s.name FROM Student s, IN (s.programs) p
ONLY if the relationship between Student and Program is either one-to-many or many-to-many.
But it is wrong if the relationship is one-to-one.(consider p.415 HFE)
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic