CMP finder efficiency

Hello. I was just wondering how to implement a component, that fetches information from a database.

I have limited myself to 2 options, either I use a Facade-DAO structure or a Facade-Entity structure. I'm sure you get the picture.

If I go with the DAO approach, I will have to go through JDBC to a database and perform an SQL-query.

The second approach would use a finder method on the entity's home interface.

The application server is BEA WebLogic 8.1. The actual search is pretty easy, only one where-clause relating to a varchar (String) field.

Since there are a lot of experienced guys out there, you propably have something to say on the performance of both of these approaches I just stated.

Will the entity-finder method perform a full table scan to the database every time the finder method is invoked? Is the entity-finder still faster than a regular jdbc-connection?

Thank you for your shared knowledge!

[966 byte] By [_Fat_Bastard_] at [2007-9-30 22:25:34]
# 1

At deployment time the EJB QL of the finder method will be translated in a SQL statement. The finder method executes this SQL statement (via JDBC). If you use a standard SQL statement, both are identical, this one of your Facade-DAO ant this of the Entity Bean. So both SQL statements will require a full table scan or not (dependent on the column types in the where clause, ...).

The performance of a Facade-DAO is better, if your search method returns very much objects.

If you use an Entity Bean with CMP and the result contains 1000 objects, the container (not optimized) executes 1001 SQL statement. The first SQL statement request all primary keys, the other 1000 statements requests a single object (call ejbLoad).

So it is depends on your database structure.

Midefix at 2007-7-7 12:48:49 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...