To provide access to various kinds of persistent storage, Spring encapsulates the relevant API in a template class. The purpose of the template class is to provide a simplifying wrapper layer around each type of storage and to ensure that any required Spring features are integrated cleanly with the persistence layer.
Spring provides the following template classes for data access:
The org.springframework.jms.core.JmsTemplate class is a general-purpose class for managing Java Messaging Service (JMS) connections. One of the main advantages of this class is that it simplifies the JMS synchronous access codes.
To create an instance of a JmsTemplate, you need
to supply a reference to a javax.jms.ConnectionFactory object.
The org.springframework.jdbc.core.JdbcTemplate class is a wrapper around a JDBC data source, enabling you to access a JDBC database using SQL operations.
To create an instance of a JdbcTemplate, you need
to supply a reference to a javax.sql.DataSource object (for example, see JDBC Data Source).
![]() | Note |
|---|---|
For a detailed discussion of the |
The org.springframework.jdbc.core.simple.SimpleJdbcTemplate
class is a convenience wrapper around the
JdbcTemplate class. This class has been pared
down so that it includes only the most commonly used template
methods and it has been optimized to exploit Java 5
features.
The org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate
class is a convenience wrapper around the
JdbcTemplate class, which enables you
to use named parameters instead of the usual ?
placeholders embedded in a SQL statement.
The org.springframework.orm.ibatis.SqlMapClientTemplate
class is a simplifying wrapper around the iBATIS
SqlMapClient class. iBATIS is an
Object Relational Mapper (ORM) that is capable of automatically
instantiating Java objects based on a given SQL database
schema.
The org.springframework.orm.hibernate3.HibernateTemplate
class provides an alternative to working with the raw Hibernate 3
session API (based on sessions returned from
SessionFactory.getCurrentSession()).
![]() | Note |
|---|---|
For Hibernate versions 3.0.1 or later, the Spring
documentation recommends that you use the native Hibernate 3
API instead of the |
The org.springframework.orm.jdo.JdoTemplate class provides an alternative to working with the raw JDO PersistenceManager API. The main difference between the APIs relates to their exception handling. See the Spring JavaDoc for details.
The org.springframework.orm.jpa.JpaTemplate class
provides an alternative to working with the raw JPA
EntityManager API..
![]() | Note |
|---|---|
The Spring documentation now recommends that you use the
native JPA programming interface instead of the
|






![[Note]](imagesdb/note.gif)


