The moose likes EJB and Other Java EE Technologies and the fly likes Entity Bean and find() method Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » EJB and Other Java EE Technologies
Reply Bookmark "Entity Bean and find() method" Watch "Entity Bean and find() method" New topic
Author

Entity Bean and find() method

Paul Medford
Ranch Hand

Joined: Aug 28, 2001
Posts: 33
Hello all,
I need some clarification regarding Entity Beans and the find() methods.
1) Users who retrieve a same record from a database using an Entity Bean, do they all have their own copy (instance) of the Entity Bean or do they all share one single instance of the bean?
2) Let's suppose a user finds a record in the database through an Entity Bean using a servlet. Once the page is displayed in the browser and the connection is closed, does the Entity Bean return immediately to the pool and therefore looses its state, or does it keep its state for the next call (in a sense caching the data for faster retrieval)?
3) Let's assume a search engine uses EJBs. If a user searches for a word that is found in say 1 million pages using a find() method, does it mean that 1 million Entity Beans were created?
4) I queried Google for the word 'eye' and it found over 9.7 million pages in just .11 seconds. Whereas it is taking for ever to find only 100,000 records on my machine. Is it just a matter of computing power or something else?
Any thought?
Francois
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3878
Originally posted by Francois Merle:
Hello all,
I need some clarification regarding Entity Beans and the find() methods.
1) Users who retrieve a same record from a database using an Entity Bean, do they all have their own copy (instance) of the Entity Bean or do they all share one single instance of the bean?

Unless you are using Option A caching the answer is they each get their own instances.

2) Let's suppose a user finds a record in the database through an Entity Bean using a servlet. Once the page is displayed in the browser and the connection is closed, does the Entity Bean return immediately to the pool and therefore looses its state, or does it keep its state for the next call (in a sense caching the data for faster retrieval)?

Unless you are using Option A caching it loses its state. This is all covered in the specification under the different Caching options (Options A, B and C).

3) Let's assume a search engine uses EJBs. If a user searches for a word that is found in say 1 million pages using a find() method, does it mean that 1 million Entity Beans were created?

Yes.

4) I queried Google for the word 'eye' and it found over 9.7 million pages in just .11 seconds. Whereas it is taking for ever to find only 100,000 records on my machine. Is it just a matter of computing power or something else?
Any thought?
Francois

The answer is that google is using very optimized search technology, not a general purpose technology like EJB's. It's also doing most of its work in the database. That's the key to making fast searches even with EJB's -- let the database do all of the work.
Kyle

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
IntelliJ Java IDE
 
subject: Entity Bean and find() method
 
Threads others viewed
NX: Primary Key and Immutable Key
Entity Bean's state could become stale after creation?
When will call ejbActivate and ejbPasivate ?
question about the way entity bean works?
My SCEA Part 1Study Notes
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture