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

EJB-QL

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mock exam question :Why is the following EJB-QL statement wrong?
SELECT s.name FROM Student s, Program p where s.subjectid=p.subjectId
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please provide some more details about the Student and Program tables.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot use JOINs in EJB-QL.
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Todor
Joins are allowed in EJB-QL. Please see the query in Pg233 of EJB Spec. Below is the query
SELECT DISTINCT OBJECT(o1) FROM Order o1, Order o2 WHERE o1.quantity > o2.quantity AND o2.customer.lastname = �Smith� AND o2.customer.firstname= �John�
[ February 29, 2004: Message edited by: Sudhir Vallam ]
 
Todor Mollov
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sudhir,
of course you are rigth but I was thinking in the context of the current thread.
So the question is : Why this EJB-QL is wrong

SELECT s.name FROM Student s, Program p where s.subjectid=p.subjectId


and the spec says on p.232

Because finder methods cannot return arbitrary types, the SELECT clause of an EJB QL query defined
for a finder method must always correspond to the abstract schema type of the entity bean for which the
finder method is defined.


and later on

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.


The given EJB-QL states that the method is select method (because of the return type), so it appeared that this EJB-QL is right.
 
This will take every ounce of my mental strength! All for a tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic