Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbPostCreate Method is it compulsory

 
Rahul Mahindrakar
Ranch Hand
Posts: 1869
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Page 124 of the EJB 1.1 specification states " for each ejbCreate(.. ) method the entity bean class must define a matching ejbPostCreate(... ) method . However when i am not defining a ejbPostCreate(.. ) method using the reference implementation things work fine.
Is there something that i am missing.
 
Ganesh Natarajan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
It is not necessary. The container will automatically call ejbPostCreate() immediately after ejbCreate().
 
Frank Lin
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rahul Mahindrakar:
Hi,
Page 124 of the EJB 1.1 specification states " for each ejbCreate(.. ) method the entity bean class [b] must
define a matching ejbPostCreate(... ) method . However when i am not defining a ejbPostCreate(.. ) method using the reference implementation things work fine.
Is there something that i am missing.
[/B]

ejbPostCreate() is a must when CMP is used. ejbCreate() is called BEFORE database insert operation. You need to use ejbPostCreate() to define operations, like set a flag, AFTER insert completes sucessfully. With BMP, you have the control over the insert, you can do that right after the JDBC call, within the ejbCreate().
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic