Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question about ejbPostCreate

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From book "master ejb 2nd", there is sth related to the usage of ejbPostCreate():

---------------------------
You might also use this method to reset certain
transaction-related parameters. For example, you
could keep a data status flag in the bean to indicate
whether a field has been changed. Because the bean
instance may have been used before, these fields
might have dirty data.
----------------------------

My question is why we need ejbPostCreate() to do the work rather than ejbCreate() ?

thanks in advance.

 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jason,

The quote above obviously applies to BMP entity beans and the exam doesn't cover them.
Now your question:

My question is why we need ejbPostCreate() to do the work rather than ejbCreate() ?



For CMP entity beans, ejbPostCreate() is typically used to update the relationships through a call to one or more CMR abstract setters.

Why do you need to wait till ejbPostCreate() for doing it? Because relationships are materialized in the db by PK/FK mappings and that in ejbCreate() the bean's PK is not available yet (the bean is said to have "no identity").

Regards,

Phil.
 
Jason Hunt
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Philippe, it is all cleared now.

 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic