• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

question about ejbPostCreate

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
thanks Philippe, it is all cleared now.

 
    Bookmark Topic Watch Topic
  • New Topic