Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

one question in ICE 287

 
Edy Yu
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Howard Kushner
author
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic