English 中文(简体)
Spring Boot ORM - Overview
  • 时间:2024-09-17

Spring Boot ORM - Overview


Previous Page Next Page  

The Spring Framework integrates well with ORM frameworks pke Hibernate, Java Persistence API (JPA), Java Data Objects (JDO) and iBATIS SQL Maps. Spring provides resource management, data access object (DAO) implementations, and transaction strategies. Spring allows to configure ORM pbrary features through dependency management. Spring maintains a uniform DAO Exception hiearchies and a generic transaction management for all the ORM pbraries it supports.

Spring IoC container faciptates ORM configurations and easy deployment. Following are the key benefits of using Spring framework to create ORM DAO.

    Easy to Test − Using spring IoC, an ORM implementation can be easily configured. Each piece of persistence unit can be tested in isolation.

    Common Data Access Exception − Spring wraps ORM Tools exceptions to a common runtime exception as DataAccessException. This approach helps to handle most persistence exception (non-recoverable) in appropriate layers. No need to handle ORM specific boilerplate catch/throws/exception declarations.

    General Resource Management − Spring apppcation contexts manages persistence objects, their configurations easily. For example, Hibernate SessionFactory instances, JPA EntityManagerFactory instances, JDBC DataSource instances, iBatis SQL Maps configuration objects and other related objects. Spring handles the local as well JTA transaction management by itself.

    Integrated transaction management − Spring AOP can be used to wrap an ORM code with a declarative AOP styled interceptor either using @Transaction annotation or by specifying transaction AOP advice in XML configuration file. Spring handles transaction semantics, exception handpng, rollback and so on. Spring allows to swap transaction managers without affecting the ORM code.

Advertisements