12.1. Introduction

Hibernate, JDO, Oracle TopLink, iBATIS SQL Maps, JPA 같은 ORM 과 Spring을 통합하여 Spring 의 Transaction 관리과 Exception 정책을 사용할 수 있습니다.

통합 하는 방법은 두 가지
1. using Spring's DAO 'templates'.
2. coding DAOs against plain Hibernate/JDO/TopLink/etc APIs.

12.2. Hibernate

Hibernate 와 연동하는 방법을 설명합니다. 주로 Hibernate 3.0 중심으로 설명 합니다.

12.3. JDO

Spring supports the standard JDO 1.0/2.0 API as data access
strategy

12.4. Oracle TopLink

Since Spring 1.2, Spring supports Oracle TopLink (http://www.oracle.com/technology/products/ias/toplink) as
data access strategy

TopLink 9.0.4, 10.1.3

12.5. iBATIS SQL Maps

The iBATIS support in the Spring Framework much resembles
the JDBC / Hibernate support in that it supports the same template style
programming and just as with JDBC or Hibernate, the iBATIS support works
with Spring's exception hierarchy and let's you enjoy the all IoC features
Spring has.

12.6. JPA

Spring JPA offers
comprehensive support for the Java
Persistence API
in a similar manner to the integration with
Hibernate or JDO

12.7. Transaction Management

선언적인 트랜잭션 관리를 위한 설정 내용 입니다.
[#M_ more.. | less.. |<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

  <bean id="myTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
    <property name="entityManagerFactory" ref="myEmf"/>
  </bean>

  <bean id="myProductService" class="product.ProductServiceImpl">
    <property name="productDao" ref="myProductDao"/>
  </bean>
 
  <aop:config>
    <aop:pointcut id="productServiceMethods" expression="execution(* product.ProductService.*(..))"/>
    <aop:advisor advice-ref="txAdvice" pointcut-ref="productServiceMethods"/>
  </aop:config>

  <tx:advice id="txAdvice" transaction-manager="myTxManager">
    <tx:attributes>
      <tx:method name="increasePrice*" propagation="REQUIRED"/>
      <tx:method name="someOtherBusinessMethod" propagation="REQUIRES_NEW"/>
      <tx:method name="*" propagation="SUPPORTS" read-only="true"/>
    </tx:attributes>
  </tx:advice>

</beans>
_M#]위 예제는 JpaTransactionManager를 사용한 경우입니다. Hibernate, Toplink, OpenJPA 를 위한 클래스도 제공합니다.

12.8. JpaDialect

Dialect 클래스를 사용함으로써 얻을 수 있는 장점들은 다음과 같습니다.
* applying specific transaction semantics (such as custom isolation level or transaction timeout)
* retrieving the transactional JDBC Connection (for exposure to JDBC-based DAOs)
* advanced translation of PersistenceExceptions  to Spring DataAccessExceptions

JDBC connection의 편리한 사용과 Transaction 그리고 DataAccessExcepion에 대한 장점은 10장, 11장에 이어 12장에서 까지 계속 얘기하네요.