Spring notes(六) - DAO and ORMapping support
Spring provides all kinds of DAO layers:
- JdbcDaoSupport: you can get JdbcTemplate.
- HibernateDaoSupport:you can get hibernateTemplate and SessionFactory
- JdoDaoSupport: you can get jdoTemplate and PersistenceManagerFactory
- JpaDaoSupport: you can get jpaTemplate and EntityManagerFactory
- SqlMapDaoSupport: you can get sqlMapDaoTemplate and SqlMapClient
So, you can extend these XxxDaoSupport to expose CRUD APIs.
In spring applicationContext.xml, you should inject Datasource, SessionFactory, PersistenceManagerFactory, EntityManagerFactory, SqlMapClient bean to these XxxDaoSupport descendants respectively, so that you can get their XxxTemplate in your DAO subclasses.
Lets see these XxxTemplates:
JdbcTemplate encapsulates Jdbc operations, so that you can use it handily. The other XxxTemplates encapsulate the respective OR-Mappings.
E.g. jdbcTemplate.queryForObject(“select **** “);
Next, i will talk about how smartly the XxxTemplates are designed. They are all best practices of Template-Method. Please keep your focus on.
Categorized in: Design Patterns, Java · Tagged with: DAO, Java, Spring


(
on 2009/01/15 at 09:50
· Permalink
老大啊。上次我问你的文章是不是原创的你还没答我呢。。麻烦有空了把答案发我邮箱里
on 2009/01/15 at 10:07
· Permalink
除标明是转载的文章外,其它都是我自己写的或者翻译的