Win a copy of High Performance Python for Data Analytics this week in the Python 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

HFEJB - Chapter 7 Questions?

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic