Typical candidate concerns include:
? Tracing and performance monitoring
? Auditing
? Notification (such as e-mailing an administrator when a certain exception is thrown)
A connection: This represents a communication session with a specific data store. Typically
connections are not thread-safe, and are thus freshly created by a connection factory for each
conversation. For JDBC, this is a Connection; for JDO, a PersistenceManager; for Hibernate,
a Session; for TopLink, a Sessionor UnitOfWork(depending on usage).
根据chapter 10 DAO pattern的一些总结:
Hibernate的transparent persistence为编程带来的一个改变是,DAO可以是coarse-grained,而传统的往往是fine-grained. 对于简单的系统,甚至于不需要DAO层,但是对于复杂一些的系统,有一个很薄的DAO层还是好的,好处在于:
1. easy for mock
2. DAOs offer a clear, strongly typed persistence API for a domain: It is immediately obvious
which persistent objects are retrieved, created, or deleted. The generic API of an O/R mapping
tool allows it to apply any persistence operation to any object, which makes it hard to find out
actually available operations for a specific domain.
3. DAOs allow finder methods with domain arguments, removing the need to maintain object
query language strings in business objects.
能coarse-grained的话,最好
读书到319页 Data Access with the Spring Framework
http://www.huachu.com.cn/news/newsinfo.asp?specialNewsID=1000001454
http://www.huachu.com.cn/news/newsinfo.asp?specialNewsID=1000001455
http://www.huachu.com.cn/news/newsinfo.asp?specialNewsID=1000001452
转载于:https://blog.51cto.com/vcycyv/407432