I'm pretty new to the whole EJB scene, so please excuse my ignorance. I'm thinking of using the Session Facade pattern for our EJB application, with bean-managed EJBs. The entity beans will look up container-configured datasource (oracle8 db) with JNDI and use that for persistence. The question I have is, at what point should the datasource connection be created and closed? As I understand, the container (jboss 4.0.0) will pool existing connections and lend them to the entity beans upon lookup. Does this mean the entity beans shouldn't close the connection on their own?
In BMP beans, you should open and close database connections in each of create(),load(),store(),findBy..(). closing a connection just return the connection to connection pool, it won't actually close the connection with database. Its handled internally by ConnectionManager.