aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes ejbcreate() and ejbStore() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "ejbcreate() and ejbStore()" Watch "ejbcreate() and ejbStore()" New topic
Author

ejbcreate() and ejbStore()

aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
While creating a record through entity bean ejbcreate() and ejbPostCreate() would be called.
Would ejbStore() be called while inserting or only while update ejbStore() is called and while insert only ejbcreate() gets called which creates a new record in db.

Thanks,
aakash
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
Hi,

While creating a record through entity bean ejbcreate() and ejbPostCreate() would be called.
Would ejbStore() be called while inserting or only while update ejbStore() is called and while insert only ejbcreate() gets called which creates a new record in db.


ejbLoad is called after the data is populated from the database, say using some findBy...() and before the business method is called. ejbStore is called just before the data is written to database.

Both ejbLoad() and ejbStore() are called by container to synchronize the fields in Database with fields in Bean and vice versa. This synchronization of data is done automatically in CMP by container and in BMP ejbStore is for update and ejbLoad is for select.

for insert ejbCreate and ejbPostCreate both are called. one after another as ejbPostCreate manages the relationship field so must be executed after ejbCreate.
aakash bhatt
Ranch Hand

Joined: Jan 09, 2003
Posts: 182
Thanks Kaur,

But my question was as ejbStore is called just before the data is written to database as in insert too we are writing the data to database, so in that wouldn't the ejbStore() should be called or the spec is written while insert the ejbcreate() does pesristence which ejbStore() should have done.


Regards,
Pradeep A
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
so in that wouldn't the ejbStore() should be called or the spec is written while insert the ejbcreate() does pesristence which ejbStore() should have done.


Sorry, I still didn't understand this line clearly. Do u mean ejbStore should have done insert which ejbCreate does for persistence.

Well, then I would say, that ejbCreate correspond to create sql statement- i.e. when a new record is inserted into database.
ejbStore correspond to update sql statement- i.e. to update sql statement to synchronize the existing record in database with the changed data in Bean.

both methods are for persistence but ejbStore is also for synchronizing as ejbLoad.
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
I correct the line above I wrote :

to update sql statement to synchronize the existing record in database with the changed data in Bean.


as

to update/synchronize the existing record in database with the changed data in Bean.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ejbcreate() and ejbStore()