aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes Iam having a doubt in ejbCreate and ejbPostcreate() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "Iam having a doubt in ejbCreate and ejbPostcreate() method" Watch "Iam having a doubt in ejbCreate and ejbPostcreate() method" New topic
Author

Iam having a doubt in ejbCreate and ejbPostcreate() method

Vasantha Prabha
Ranch Hand

Joined: Oct 02, 2003
Posts: 108
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
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
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
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Iam having a doubt in ejbCreate and ejbPostcreate() method
 
Similar Threads
Doubt in Transaction
Thread doubt ??
Doubt regarding Innerclasses
I doubt my garbage collection
Doubt