• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFEJB - Chapter 7 Questions?

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was just wondering if someone could confirm that the following two questions in HFEJB give incorrect answers. I've checked the books errata and they are both listed in the unconfirmed section.

Question 4:
Given the container-managed undirectional relationshop:

Foo(0-1) -> Bar (0-1)

And the object relations:

f1 -> b1
f2 -> b2

What will be true after the following code runs? (Choose all that apply)

f2.setBar(f1.getBar()):

A. f1.getBar() == null
B. b2.getFoo() == null
C. b1.getFoo() == null
D. None of the above.

Question 12.

Given CMP beans CustomerBean, OrderBean, LineItemsBean with the following relationships:

CustomerBean(1) <-> OrderBean(n)
OrderBean(1) <-> LineItemsBean(n)

Which will return all orders that have line items? (Choose all that apply.)

A. SELECT DISTINCT o FROM Order.o, IN (o.lineItems) li
B. SELECT DISTINCT OBJECT(o) FROM Order o, IN (o.lineItems) li
C. SELECT OBJECT(o) FROM Order o WHERE o.lineItems = 0
D. SELECT OBJECT(o) FROM Order o

For Question 4 only A should be correct cause with Unidirectional CMR Bar won't have a getFoo() method.

For Question 12 only B should be correct cause that will return all lineItems in Order.

In the book, question 4 has A and B as correct and question 12 has B and D correct.
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, there have been quite a few posts about this question -- mainly being that some of the answer choices are syntactically invalid (won't compile). All this of course having to do with the directional nature of the association. Good eye.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matt,

For Question 4, only A should be correct. Because with Unidirectional CMR, Bar won't have a getFoo() method. So you are correct on that point.

Question 12:
Which will return all orders that have line items?

IMO, correct answer should be:
SELECT OBJECT(o) FROM Order o WHERE o.lineItems IS NOT EMPTY

Option D would not discard duplicate Orders in result, but it would return all Orders from Order table irrespective of whether Order has lineitems or not.

Option A would discard duplicate Orders in result, but it would return Orders from Order table irrespective of whether Order has lineitems or not.



The above query would simply create identification variable o for Order and li for Lineitem. It would not verify whether Order has at least one lineitem or not.

So I would say there should be an option to select:
E] None of the above

Please correct me if I am wrong in my understanding.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Sorry All,

I posted my reply quite early with out refering Specs. Let me take back my words and say after being enlightened:


Find all orders that have line items:


The result of this query does not include orders with no associated line items. This query can also be written as:


So correct answer is A]

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help guys. I guess I should have done a search of the board first, but it slipped my mind.

With regard to the specs are they available in a printed form? I've downloaded them from the web, but never refer to it cause I find it easier to read up and search for things from a book. I'm thinking it might be easier to get used to reading up from electronic versions though!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic