File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes why we are using ejbPostCreate() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "why we are using ejbPostCreate() " Watch "why we are using ejbPostCreate() " New topic

why we are using ejbPostCreate()

basanta dwibedy

Joined: Feb 05, 2007
Posts: 23
Hi ,

can any body give the answer why exactly in a Entity Bean we are using ejbPostCreate() method.

what is the exact differnece between ecjCreate() method and ejbPostCreate() method.
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

ejbPostCreate gives you a chance to set cmr-fields. It is not possible in ejbCreate as the entity does not exist yet.

[My Blog]
All roads lead to JavaRanch
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
To elaborate further. Relationship tables require the primary key information of the parent table of the relationship. Some times primary key generation is deferred to the database(e.g. trigger based PK generation). In such cases PKs are generated on completion of the ejbCreate method invocation. Hence an ejbPostCreate method is provided to retrieve the PK and assign it to the relationship tables.
I agree. Here's the link:
subject: why we are using ejbPostCreate()
It's not a secret anymore!