Iam having a doubt in ejbCreate and ejbPostcreate() method
Vasantha Prabha
Ranch Hand
Joined: Oct 02, 2003
Posts: 108
posted
0
Hi, Iam leaving EJB.Iam having a doubt in that like do we need ejbpostcreate() for eachejbcreate() method ?? Regards, Sangeetha
Regards,Vasantha<p>Great minds discuss ideas. Average minds discuss events. Small minds discuss people.
Sergiu Truta
Ranch Hand
Joined: Dec 16, 2003
Posts: 121
posted
0
you need an ejbPostCreate() for each ejbCreate() because in case you have a relationship this must be set inside ejbPostCreate(). If you are thinking now "but why do I have to have it if I don't implement any relationship?", it's pretty obvious that the SUN engineers could not make "some" specification for "some other" cases. The specifications are general and should include all the cases. So if you don't implement any relationship you simply have an empty ejbPostCreate() with the same signature as ejbCreate().
...watch me...as I'm walking the path...
Vasantha Prabha
Ranch Hand
Joined: Oct 02, 2003
Posts: 108
posted
0
Can please explain me what type of relationship will be provided in the ejbpostcreate() method of a paticular ejbcreate() method. Regard, Sangeetha
Sergiu Truta
Ranch Hand
Joined: Dec 16, 2003
Posts: 121
posted
0
For example you have two beans: Company and Employee in a 1 to N relationship (a company may have many employees). In the Employee table you have a field like "Company_PK". Here you could use a CMR (Container Managed Relationship) and for example when saving a new employee, you have to set a company to which that employee belongs to. So: 1) in ejbCreate() you save all the necesary data for the employee 2) in ejbPostCreate() you save the company (not as a BigDecimal/Double or whatever you use!) as a CompanyLocal:
setCompany(companyLocal); Read about CMR and this will clear out. hope this helps