• 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
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.

 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic