• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbCreate()  RSS feed

 
Nick Faiz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is ejbCreate() defined, if not in, for example, the SessionBean interface?
Thanks,
Nick
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not defined in a specific interface. It is only defined in your EJB.
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ejbCreate method is not defined in a Java interface. However, it is defined by the EJB spec as an expected method in the local or remote interfaces.
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually there is more to it than that. You have a create method in the home interface, and a matching ejbCreate method in the bean class. They have to have a matching set of parameters as well. These are the rules according to the EJB spec.
 
Nick Faiz
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replies, Matthew and Dave.
Nick
 
Manish Malhotra
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is ejbCreate is used to create the table in the batabase with which our BMP will interact?
Manish Malhotra.
S/w Engg.
Working.
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy
For a BMP bean, you use ejbCreate to physically do the insert of a new 'entity' into the database (i.e. probably a new row). The container is expecting the primary key as the return, so that it can then create the EJBObject and stub, and load them with the primary key.
For every create in the home, you must also have a matching ejbPostCreate, which for a BMP bean you might not use, but it's there in case you need to complete initializing the entity *after* the EJBObject has been created. The high-level steps are (assuming the client has called create on an entity bean home):
1) ejbCreate is called on the bean
-- do the insert and return primary key
2) container makes the EJBObject and stub
3) ejbPostCreate is called and you then have a chance to USE the EJBObject now that it exists (use your EntityContext to get a reference to it)
4) the client gets back the stub to the EJBObject
I *think* that's it... we haven't done BMP in a long time, though, so I'm doing this from dusty memories.
cheers,
Kathy
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!