| | + title | Ref. /chapter[1]/title[1] |
| Original | Traduction | DAO support |
| sect1
| | + title | Ref. /chapter[1]/sect1[1]/title[1] |
| Original | Traduction | Introduction |
|
| + para | Ref. /chapter[1]/sect1[1]/para[1] |
| Original | Traduction | The DAO (Data Access Object) support in Spring is primarily aimed at
making it easy to work with data access technologies like JDBC, Hibernate
or JDO in a standardized way. This allows you to switch between them
fairly easily and it also allows you to code without worrying about
catching exceptions that are specific to each technology. |
|
| | sect1
| | + title | Ref. /chapter[1]/sect1[2]/title[1] |
| Original | Traduction | Consistent Exception Hierarchy |
|
| + para | Ref. /chapter[1]/sect1[2]/para[1] |
| Original | Traduction | Spring provides a convenient translation from technology specific
exceptions like SQLException to its own exception
hierarchy with the DataAccessException as the root
exception. These exceptions wrap the original exception so there is never
any risk that you would lose any information as to what might have gone
wrong. |
|
| + para | Ref. /chapter[1]/sect1[2]/para[2] |
| Original | Traduction | In addition to JDBC exceptions, Spring can also wrap Hibernate
exceptions, converting them from proprietary, checked exceptions, to a set
of abstracted runtime exceptions. The same is true for JDO exceptions.
This allows you to handle most persistence exceptions, which are
non-recoverable, only in the appropriate layers, without annoying
boilerplate catches/throws, and exception declarations. You can still trap
and handle exceptions anywhere you need to. As we mentioned above, JDBC
exceptions (including DB specific dialects) are also converted to the same
hierarchy, meaning that you can perform some operations with JDBC within a
consistent programming model. |
|
| + para | Ref. /chapter[1]/sect1[2]/para[3] |
| Original | Traduction | The above is true for the Template versions of the ORM access
framework. If you use the Interceptor based classes then the application
must care about handling HibernateExceptions and JDOExceptions itself,
preferably via delegating to SessionFactoryUtils'
convertHibernateAccessException or
convertJdoAccessException methods respectively. These
methods converts the exceptions to ones that are compatible with the
org.springframework.dao exception hierarchy. As JDOExceptions are
unchecked, they can simply get thrown too, sacrificing generic DAO
abstraction in terms of exceptions though. |
|
| + para | Ref. /chapter[1]/sect1[2]/para[4] |
| Original | Traduction | The exception hierarchy that Spring uses is outlined in the
following graph: |
|
| | sect1
| | + title | Ref. /chapter[1]/sect1[3]/title[1] |
| Original | Traduction | Consistent Abstract Classes for DAO Support |
|
| + para | Ref. /chapter[1]/sect1[3]/para[1] |
| Original | Traduction | To make it easier to work with a variety of data access technologies
like JDBC, JDO and Hibernate in a consistent way, Spring provides a set of
abstract DAO classes that you can extend. These abstract classes has
methods for setting the data source and any other configuration settings
that are specific to the technology you currently are using. |
|
| + para | Ref. /chapter[1]/sect1[3]/para[2] |
| Original | Traduction | Dao Support classes: |
|
| + para | Ref. /chapter[1]/sect1[3]/itemizedlist[1]/listitem[1]/para[1] |
| Original | Traduction | JdbcDaoSupport - super class for JDBC data
access objects. Requires a DataSource to be set, providing a
JdbcTemplate based on it to subclasses. |
|
| + para | Ref. /chapter[1]/sect1[3]/itemizedlist[1]/listitem[2]/para[1] |
| Original | Traduction | HibernateDaoSupport - super class for
Hibernate data access objects. Requires a SessionFactory to be set,
providing a HibernateTemplate based on it to subclasses. Can
alternatively be initialized directly via a HibernateTemplate, to
reuse the latter's settings like SessionFactory, flush mode, exception
translator, etc. |
|
| + para | Ref. /chapter[1]/sect1[3]/itemizedlist[1]/listitem[3]/para[1] |
| Original | Traduction | JdoDaoSupport - super class for JDO data
access objects. Requires a PersistenceManagerFactory to be set,
providing a JdoTemplate based on it to subclasses. |
|
| |
|