Saturday, March 29, 2003 06:33 AM
You're forgetting one thing: not all rows in the table are needed at the same time. Usually, when you queury the database, you qualify your search with a where clause so that a limited number of rows (and entity beans) are returned. If, on the other hand, you truly need to read half a million rows, you'd be better off with jdbc cursors.
As far as being expensive in terms of RAM usage, remember that the EJB container manages a pool of anonymous entity beans. Beans are taken out of cache and assigned to specific rows by the container and are placed back into the cache when the transaction completes. So while this consumes memory, it speeds up the process of getting data in and out of the database. For read-only entity beans, it allows rows to be cached and represented as entity beans without ever going to the database.