wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes ejbPostCreate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbPostCreate " Watch "ejbPostCreate " New topic
Author

ejbPostCreate

william kane
Ranch Hand

Joined: Nov 21, 2000
Posts: 260
What is the typical implemetation of the ejbPostCreate method in an entity bean?


Help me!Help you!!!
Siva Jagadeesan
Ranch Hand

Joined: Oct 31, 2000
Posts: 160
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


Rgds<p>--Siva Jagadeesan<br /><a href="http://java2simple.blog-city.com" target="_blank" rel="nofollow">http://java2simple.blog-city.com</a><br />Sun Certified Java2 Programmer<br />Sun Certified Web Component Developer<br />BEA Certified Weblogic Server 7 Enterprise Developer
william kane
Ranch Hand

Joined: Nov 21, 2000
Posts: 260
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

Joined: Oct 31, 2000
Posts: 160
You are welcome Kane
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbPostCreate