Should I transfer or encapsulate a connection in a DAO?

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?

+5
source share
4 answers

The DAO must perform CRUD operations and hide these operations from callers. Therefore, you must encapsulate the connection.

, DAO (, ), DAO ( , , DAO).

- . , DAO ? , .

+3

, , , DAO . , , .

, /-, DAO, , DAO? , , .

DAO, , , , IMO.

+2

, DAO , , . . DAO , , .

0
source

All Articles