Spring notes(六) - DAO and ORMapping support

Spring provides all kinds of DAO layers:

  1. JdbcDaoSupport: you can get JdbcTemplate.
  2. HibernateDaoSupport:you can get hibernateTemplate and SessionFactory
  3. JdoDaoSupport: you can get jdoTemplate and PersistenceManagerFactory
  4. JpaDaoSupport: you can get jpaTemplate and EntityManagerFactory
  5. 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.

By javafuns on March 18, 2008 at 23:35 · Views: 1,257 · Permalink
Categorized in: Design Patterns, Java · Tagged with: , ,
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

2 Responses

Subscribe to comments via RSS

  1. Written by 开平
    on 2009/01/15 at 09:50
    Reply · Permalink

    老大啊。上次我问你的文章是不是原创的你还没答我呢。。麻烦有空了把答案发我邮箱里

    • Written by javafuns
      on 2009/01/15 at 10:07
      Reply · Permalink

      除标明是转载的文章外,其它都是我自己写的或者翻译的

Subscribe to comments via RSS

Leave a Reply


  • Highest Rated

  • My PicasaPhotos

    IMG_0549.JPG

    IMG_0553.JPG

    IMG_0535.JPG

  • RSS My del.icio.us

  • My RSS