Tuesday, 19 April 2016

ejbCreate() vs. ejbPostCreate()


The purpose of ejbPostCreate() is to perform clean-up database operations after SQL INSERTs [ which occur when ejbCreate() is called ] when working with CMP entity beans. ejbCreate() is called before database INSERT operations.
You need to use ejbPostCreate() to define operations, like set a flag, after INSERT completes successfully.

When working with BMP entity beans, this is not necessary. You have full control over the entire process, so you can place all the necessary logic surrounding your INSERT statement directly in the ejbCreate() method.

Even if you are creating BMP entity beans, the recommendation would still be to include an empty ejbPostCreate() method.
Although some application servers will not enforce it, the spec indicates that this placeholder should be there.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.