Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbCreate( ) + ejbRemove( )  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers.
I need some help tips here.
As you know guys, in Entity Beans, we have ejbCreate( ) and ejbRemove( ) methods.
My questions is:
1. In ejbCreate( ) method: should create a new data (inserting in a database) or use it for finding an existing data?
(just like a parameter represeting the username, then ejbCreate( ) will return this user?)
2. In the ejbRemove( ) method, should I implement this method to delete the specific data from a database,or should I leave it without implementation?
(I mean, if I have an entity bean represents a customer, I don't want to lose this customer if the container want to destroy this entity bean!, or we need to stop the container for some reason).
 
Viraj Sing
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
===========================================================================
Hi ranchers.
I need some help tips here.
As you know guys, in Entity Beans, we have ejbCreate( ) and ejbRemove( ) methods.
My questions is:
1. In ejbCreate( ) method: should create a new data (inserting in a database) or use it for finding an existing data?
(just like a parameter represeting the username, then ejbCreate( ) will return this user?)
2. In the ejbRemove( ) method, should I implement this method to delete the specific data from a database,or should I leave it without implementation?
(I mean, if I have an entity bean represents a customer, I don't want to lose this customer if the container want to destroy this entity bean!, or we need to stop the container for some reason).
============================================================================
Hi John,
1. The ejbCreate is used to insert data in the database. To find the existing data use the findByPrimaryKey method..
The ejbCreate returns the PrimaryKey object in the case of BMP.
The ejbCreate returns NULL In the case of CMP.
The findByPrimaryKey method returns you the EJBObject and the ejbFindByPrimaryKey would return you the PrimaryKey object.
Hence when the client invokes a findByPrimaryKey mthod, the container would issue a call to ejbFindByPrimaryKey method that returns the PrimaryKey. Using that it would find the right Entity Bean instance and associate with a EJBObject and returns the EJBObject back to the client.
2. The ejbRemove method needs to be implemented. I am not clear with your question. But from my knowledge, the container would not remove an entity bean instance just like that. The ejbRemove() is not a call back method.
Imagine you have only 10 instances of Entity Beans instances each representing a row in the Customer table. If the 11'th customer comes into picture, then the container would passivate an existing Entity Bean instance by first calling the ejbStore method and then the ejbPassivate method. Then it would load a new data into the Entity Bean instance using the ejbActivate and ejbLoad call back methods to service the 11'th customer.

Hope this clears your question..

Thanks and regards
-Raj
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!