I have a Session Bean that need to select
> some data from a database table.
> I need to use a findXXX() method of the
> home interface of the entity bean related to
> the table, or the session bean can directly
> query the DB via JDBC ?
In my experience you should strive to use the findByXxxxx() method of the home interface. It has the benefit of loading the data from the database into the cache you will only lock entities which are actually retrieved from the collection returned by the findByXxxx() method.
Mixing direct JDBC calls with entity beans often causes trouble. There is no way for the application server to detect that your are changing data in the database behind the scenes so in effect you are messing up the cache. Remember also that the application server has its own transaction manager which is separate from the DBMS.
There is nothing wrong in using JDBC directly from a session EJB but you should probably take care not to mix the two without being very carefull. I have been surprised a couple of times :-)
Finally, writing a simple EJB QL is very easy and involves 1/10 of the code!