Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ejbCreate()

 
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
 
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.
 
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
 
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.
 
Cowgirl and Author
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
 
If you are using a rototiller, you are doing it wrong. Even on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic