• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbPostCreate

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the typical implemetation of the ejbPostCreate method in an entity bean?
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used to go crazy to understand this concept. But some how I got it. Thanx to one of my friend.This ejbPostCreate is used in a very rare situation. Before telling the situation, let me explain the difference between (or relationship) between ejbCreate and ejbPostCreate in Entity Bean. ejbPostCreate() is called by the EJB Container after the ejbCreate().The only difference is ejbPostCreate method will have the reference to the ejbObject and ejbCreate() will not have reference to ejbObject. So when you have a child parent relationship between two beans , and when you are loading the parent Bean you want to load or intialize the child bean. Then when you want to load the child bean you need to pass the instance of the Parent Bean.So you could not intialize the child bean in the ejbCreate of the parent bean as you will not have the reference to the ejbObject ( remember the bean reference passed is always ejbObject not "this" i.e.., the bean itself) . That is why we need a extra method in case of Entity bean to intialize the Child Bean
I hope I have explained , but let me know if I am not clear. This is a very easy concept, but a hard one to explain
 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey shiva kumar,
Thanks for that detailed reply.I knew that postcreate is called after the bean in associated with the entity instance in the underlying database.What i did not know is where i need to use it.Your parent child case is a good situation thanks
 
Siva Jagadeesan
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are welcome Kane
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic