• 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
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

CMP scenario

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question is pulled from the Sample Test for IBM Test 287.
Here's the question:
An "account" CMP bean has a container-managed relationship to a "customer" CMP bean. The account table reflects a relationship with a foreign key relating to the customer table. The foreign key is declared with a "NOT NULL" constraint. When creating a new account for a customer the developer MUST:
A. set the customer in the ejbCreate method of the account bean
B. set the customer in the ejbPostCreate method of the account bean
C. set the account in the ejbPostCreate method of the customer bean
D. provide a local interface for the customer CMP entity bean
Select 2 answers and explain why.
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think B and D are correct,
A) The account bean may not know the primary key of customer bean.
B) According to spec the cmr fields should be set in ejbCreate.
C) is not a must because the customer bean can be created independent of the account bean.
D) is must correct bcos cmr only uses Local interfaces.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I Think A and C are the correct answers. As a insert will take place after ejbCreate so we have to associate customer with accout otherwise we will get a null pointer exception. Other way is to associate account in ejbPostcreate of Customer because we can create a Customer without getting a NP Exception.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A is wrong because setting CMR fields is prohibited in ejbCreate() <*1>
B is correct because CMR fields should be set in ejbPostCreate() <*1>
C is wrong because the account bean was not mentioned to have a local interface (?) <*2>
D is correct because CMR requires a local interface <*2>

<*1> EJB 2.0 spec, chapter 10.5.2, page 171
<*2> EJB 2.0 spec, chapter 5.4, page 54
 
Vinod John
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vinod John:
B) According to spec the cmr fields should be set in ejbCreate.


I should have been
"According to spec the cmr fields should be set in ejbPostCreate."
Sorry I typed it wrong
But on a second thought A could be more appropriate than be B(though the spec is on the contrary. As the foreign key is a NOT NULL column, so there is a chance of getting a constraint violation (if you don't set the column to be defererable in the database) ... If this is a Sun certification B is a better answer, but for pratical purpose A could be better ???
[ July 24, 2003: Message edited by: Vinod John ]
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic