Is it better to encapsulate the connection inside the DAO, i.e. create a DAO or get a connection, and then close or is it better to pass the connection to the DAO and process the details in code external to the DAO?
Follow-up: How can you hide the closure of connections if you encapsulate a connection inside a DAO?
The DAO must perform CRUD operations and hide these operations from callers. Therefore, you must encapsulate the connection.
, DAO (, ), DAO ( , , DAO).
- . , DAO ? , .
, . , DAO / (, Factory) , .
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
- ?
, , , DAO . , , .
, /-, DAO, , DAO? , , .
DAO, , , , IMO.
, DAO , , . . DAO , , .