This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Product and Other Certifications and the fly likes one question in ICE 287 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "one question in ICE 287" Watch "one question in ICE 287" New topic
Author

one question in ICE 287

Edy Yu
Ranch Hand

Joined: Nov 21, 2000
Posts: 264
24. While testing the create method of a CMP entity bean using the Universal Test Client of IBM WebSphere Studio Application Developer, the following exception is thrown: ... Exception: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] ... SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "LIBRARY.PATRON" from having duplicate rows for those columns. SQLSTATE=23505 Which of the following is the BEST place to set the breakpoint?
A. The ejbCreate method
B. The create method
C. The ejbPostCreate method
D. The ejbStore method

Select the best answer.
Can anybody give me answer to it and explain why?
Thanks in advance.


SCJP, SCJD, SCWCD, SCBCD, SCEA, IBM Certified Enterprise Developer, WebSphere Studio V5.0
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
I think the answer is A.
Obviously, B is incorrect because the Entity Bean does not contain a create() method, since this is defined in the home interface, and when it is implemented in the bean, the ejb prefix will be added.
D is incorrect because the DB is complaining about the primary key violation. It will be correct, if the error is solely about saving the bean data, without any key issues.
In fact, choice A and C are quite similar, however, ejbPostCreate() is used to finish any actions that cannot be performed in ejbCreate() as the bean is not completely created at that moment. However, upon ejbCreate() is completed, the bean is created and the data is appear in the DB. Thus, if a data item cannot be inserted into the DB due to PK violation, problems should be appeared in ejbCreate().
Does this make sense?
Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Howard Kushner
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 361
Originally posted by Nicholas Cheung:
I think the answer is A.
Obviously, B is incorrect because the Entity Bean does not contain a create() method, since this is defined in the home interface, and when it is implemented in the bean, the ejb prefix will be added.
D is incorrect because the DB is complaining about the primary key violation. It will be correct, if the error is solely about saving the bean data, without any key issues.
In fact, choice A and C are quite similar, however, ejbPostCreate() is used to finish any actions that cannot be performed in ejbCreate() as the bean is not completely created at that moment. However, upon ejbCreate() is completed, the bean is created and the data is appear in the DB. Thus, if a data item cannot be inserted into the DB due to PK violation, problems should be appeared in ejbCreate().
Does this make sense?
Nick

Makes sense to me!


Howard Kushner<br />IBM Certified Enterprise Developer - WebSphere Studio Application Developer V5.0<br />IBM Certified Advanced System Administrator - WebSphere Application Server V5.0<br />IBM Certified Solution Developer - Web Services with WebSphere Studio V5.1<br /><a href="http://www.amazon.com/exec/obidos/tg/detail/-/1931182108/" target="_blank" rel="nofollow">Developing J2EE Applications with WebSphere Studio</a> my Certification Study Guide for IBM Test 287
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: one question in ICE 287