• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

ejbCreate( ) + ejbRemove( )

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Paper jam tastes about as you would expect. Try some 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
reply
    Bookmark Topic Watch Topic
  • New Topic