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.
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.
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 ]
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.
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)