• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

valid EJB QL query

 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a question from the final mock exam of HFEJB. I am going for exam tomorrow morning, so it will be greatly appreciated if someone can answer this before tomorrow morning (to be more specific, in around 7 hours from now on)

The Q58 of HFEJB:
Given CMP beans CustomerBean(CB), OrderBean(OB) and LineItemsBean(LIB) with relationships:
CB(1) -> OB(n)
OB(1) -> LIB(n)

Which will return set of customers that have orders?
Correct answer given is:
select distinct object(c) from Customer c, Order o where c.custnum=o.custnum.

How is this a valid query??? Customer to Order is 1 to many, so the right query should be
select distinct object(c) from Customer c, IN (c.Order) o;

See the similar example given on page 236 of the spec?

Can someone please check and comment on this?
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another such question, whose answer is confusing me:

Q.65 Which cases can cause SB instance to be destroyed without container calling ejbRemove() method?

One of the correct options given is:
An inactive client timed out while bean is in passivated state.

Here shall it be client timed out or bean timed out?
 
mohan dodderi
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ankith both are correct.

select distinct object(c) from Customer c, Order o where c.custnum=o.custnum.

actually intension of using relationship is to retrieve data from more than one table.a well formed queury always should work whether it is one-one one-many. and EJB-QL is replica of Standard SQL except some oo benifits like traversing..etc.. so above ejb-query will give the expected result.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic