For performance reasons, we have implemented a hybrid EJB/direct-JDBC implementation. Essentially, for queries that produce large result sets, I have implemented direct JDBC calls within our many session facade beans. These JDBC calls are interspersed with some basic entity bean lookups that have produced a significant performance increase.
Example code in a session bean:
------
SiteStatusLocal siteStatusEjb = siteHome.findByName(...) ConnectionWrapper wrapper = ConnectionWrapper.getInstance(); Connection conn = wrapper.getConnection(); PreparedStatement stmt = wrapper.getPreparedStatement(conn, ....); stmt.setInt(1, siteStatusEjb.getId()); ResultSet result = stmt.executeQuery()
Also, I am seeing occasional javax.ejb.ObjectNotFoundExceptions under light stress. The data is present in the database and the exception only occurs in 'batches' (that is, many exceptions for a short period, then none for an extended period).