• Post Reply Bookmark Topic Watch Topic
  • New Topic

Does LocalHome.create(...) method insert the record into database ?

 
raminaa niilian
Ranch Hand
Posts: 551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your help.

my question is :
Does LocalHome.create(...) method insert the record into database ?
for example :
I have a cmp , now i want to insert a new record into database by using it.
does following statement do this ? indeed i should ask does create(...) method of
LocalHome ?
 
Pranav Shukla
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

When you call create on EJBLocalHome of a CMP entity bean, the following things happen.

1. Container picks up any bean instance which is in pooled state.
2. Container invokes ejbCreate(<METHOD_PARAMS> - it should set the persistent properties of the bean instance and provide a valid value of the primary key property.
3. Container actually inserts the record into DB.
4. Container invokes ejbPostCreate(<METHOD_PARAMS>
5. Associates the bean instance to an EJBLocalObject - EJBLocalObject will also get the PrimaryKey of the bean.

Then it returns the reference of the EJBLocalObject to the caller.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!