Spring's data access framework
addresses the common challenges developers encounter when working with
databases in applications. Support is provided for all popular Java data access
frameworks: JDBC, iBatis / MyBatis, Hibernate, JDO, JPA, Oracle TopLink, Apache
OJB and Apache Cayenne, among others.
For all these supported
frameworks, Spring provides these features
Resource management - automatic
acquisition and release of database resources
Exception handling - translation
of the data access exception to a data access hierarchy Spring
Participation in transactions -
transparent participation in current transactions
Unpacking resources - retrieving
database objects from connection pool envelopes
All of these features are
available when you use Spring model classes provided for each supported
infrastructure. Critics have said that these template classes are intrusive and
offer no advantage over using (for example) the Hibernate API directly. [17]
[not in the given citation] In response, Spring developers have made it
possible to use the Hibernate and JPA APIs directly. However, this requires
transparent transaction management because the application code no longer
assumes responsibility for obtaining and closing database resources and does not
support exception translation.
With Spring's transaction
management, its data access framework offers a flexible abstraction to work
with data access frameworks. Spring Framework does not have a common data
access API; Instead, the total power of the supported APIs is retained intact.
Spring Framework is the only framework available in Java that provides managed
data access environments outside of an application server or container.
When using Spring to manage
transactions with Hibernate, the following beans can be configured:
· data
source like com.mchange.v2.c3p0.ComboPooledDataSource or
org.apache.commons.dbcp.BasicDataSource
· SessionFactory
as org.springframework.orm.hibernate3.LocalSessionFactoryBean with a DataSource
attribute
· HibernateProperties like
org.springframework.beans.factory.config.PropertiesFactoryBean
· TransactionManager
like org.springframework.orm.hibernate3.HibernateTransactionManager with a
SessionFactory attribute

No comments:
Post a Comment