• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

use of ejbPostCreate

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the the differernt between ejbCreate() and ejbPostCreate() .when we will use those methods.what is their purpose?
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a create() method is invoked on the home interface of an Entity Bean, EJB container invokes the corresponding ejbCreate() method. For each ejbCreate() method, you must write an ejbPostCreate() method in the entity bean class. The EJB container invokes ejbPostCreate immediately after it calls ejbCreate().In entity beans we do not have an EJBObject during the execution of ejbCreate(). However, we do have an EJBObject by the time ejbPostCreate() is executed. The ejbPostCreate() method gives us a chance to do extra initialization after the CMP fields are initialized, but before the entity bean is used by other beans. We can't accesss getPrimaryKey() and getEJBObject() methods of EntityContext in ejbCreate(), we can do it in ejbPostCreate(). In entity bean, ejbCreate() method only creates a new record in underlying database, but primary key is not associated with that object, ejbPostCreate() method allows the ejbObject to associate it with Primary Key generated.

Hope this help!!


Thanks,
Mahesh

-----------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
 
rajareddy annavaarm
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for giving me reply.

i heard we can use ejbPostCreate() method for CMR.is it right?if so how?
 
Mahesh Desai
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To set up the CMR fields during the creation of a bean, sometimes we might need primary key and we can not get it in ejbCreate method. And also we can not invoke methods like getEJBObject(), getEJBLocalObject(), or getPrimaryKey() in ejbCreate. So we use ejbPostCreate method to set the values of cmr-fields to complete the initialization of the entity bean instance.


Thanks,
Mahesh

-----------
SCJP 1.4 | SCWCD 1.4 | SCBCD 1.3 | SCEA Part I - In Progress
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic