• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Why use ejbpostcreate() after that ejbcreate()

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Freind
I try to know that why we use ejbpostcreate although we are using ejbcreate() after that using ejbpostcreate() why can anyone say about it

Thanks & regards
Rajesh Pandey
Mob:- +919811903737
email:- [email protected]
Freelance Software Developer
india Delhi
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just an way to add hooks at different times. As you might have something available later that isn't available now.

However, now with EJB3 and AOP you can basically do the same thing without having all these interface methods like ejbPostCreate to get hooks in there.

Mark
 
author
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ejbPostCreate() is called after the bean has been written to the database and the bean data has been assigned to an EJB object, so when the bean is available.

It is between ejbCreate and ejbPostCreate that the bean's proxy EJBObject is created.


In an CMP Entity EJB, this method is normally used to manage the beans' container-managed relationship fields.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you can imagine one to many relationship like One Customer can place multiple Orders (1..*)then you can understand that record in customer is a must to have a record(s) in order table right?

In ejbCreate() you(BMP....say container in case of CMP) can insert a row in Customer if this is successful then ejbPostCreate() will be called (where you cam do a data insertion in Order table)ensuring data integrity.


Obviously this is one of the use....One important thing to remember is Primary Key is avaialble in ejbPostCreate() & not in ejbCreate()method
I hope this helps

Shrinivas
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another difference, as you start mucking around with performance tuning options in a container, is that you'll find the database activities that correspond to ejbCreate and ejbPostCreate will shift around. Sometimes you can improve performance sometimes by delaying commits until after the post-create, but typically at a cost of a simple create exception instead of a duplicate key exception when you try to insert an already-used PK.
[ March 13, 2006: Message edited by: Reid M. Pinchback ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic