Thursday, September 17, 2009

DAO Support in Spring Framework

Today, there are no of Data Access technologies available such as JDBC, JDO, Hibernate and JPA etc. If we talk about Spring framework, Spring supports almost all type of Data Access Technologies in a consistent way. The important thing is that, Spring Allows to switch between any Data Access Technology without worrying about Exceptions handling for a particular data-access technology.

Spring provides no. of abstract classes for DAO Support. These abstract classes have methods for providing the data source and any other configuration settings that are specific to the relevant data-access technology.

• JdbcDaoSupport - superclass for JDBC data access objects. Requires a DataSource to be provided; in turn, this class provides a JdbcTemplate instance initialized from the supplied DataSource to subclasses.

• HibernateDaoSupport - superclass for Hibernate data access objects. Requires a SessionFactory to be provided; in turn, this class provides a HibernateTemplate instance initialized from the supplied SessionFactory to subclasses. Can alternatively be initialized directly via a HibernateTemplate, to reuse the latters settings like SessionFactory, flush mode, exception translator, and so forth.

• JdoDaoSupport - super class for JDO data access objects. Requires a PersistenceManagerFactory to be provided; in turn, this class provides a JdoTemplate instance initialized from the supplied PersistenceManagerFactory to subclasses.

• JpaDaoSupport - super class for JPA data access objects. Requires a EntityManagerFactory to be provided; in turn, this class provides a JpaTemplate instance initialized from the supplied EntityManagerFactory to subclasses.

No comments:

Post a Comment