Kai Tao Spring3 (8.1)-8.1 Overview of ORM Support

Source: Internet
Author: User
Tags relational database table

8.1 Overview 8.1.1 ORM Framework

ORM Full-Name Object-relational mapping (Object/relation Mapping), which refers to the automatic mapping of Java object State to data in a relational database, provides transparent persistence support, which translates one form into another.

There is a mismatch between the object and the relational database, and we call this mismatch the impedance mismatch, which is mainly manifested in:

    • Relational database first does not support object-oriented technology such as inheritance, polymorphism, how to make relational database support them;
    • A relational database is a table that holds the data, while object-oriented objects are used to hold the state, where the columns of the table are called properties, and the properties of the objects are attributes, so this mismatch needs to be resolved;
    • How to persist an object transparently to a relational database table;
    • If an object has data across multiple tables, how to model and map the object.

These impedance mismatches are just a few of them, such as how to map the SQL aggregate function result set to an object, how to handle the primary key in an object, and so on.

ORM Framework is used to solve this kind of impedance mismatch and provide the object support of relational database.

ORM Framework is not omnipotent, also conforms to the 80/20 Law , the most important problem should be solved is how to map the rows and objects in the relational database table, and automatically persist the object to the relational database.

ORM Solutions are designed to address transparent persistence, small result set queries, and large result set data processing without any help for complex queries.

There are already many ORM frameworks, such as Hibernate, JDO, JPA, Ibatis, and so on, each of these ORM frameworks has its own features, and spring provides good support for these ORM frameworks, so let's start by looking at how spring supports these ORM frameworks.

8.1.2 Spring's support for ORM

Spring's support for ORM is mainly reflected in the following areas:

    • A consistent exception architecture that wraps the proprietary exceptions thrown by the third-party ORM framework so that we only see the DataAccessException exception system in spring;
    • Consistent DAO abstraction Support: Provides DAO support class Hibernatedaosupport similar to Jdbcsupport, using Hibernatetemplate template classes to simplify common operations, Hibernatetemplate provides callback interfaces to support complex operations;
    • Spring Transaction Management: Spring provides consistent transaction management for all data access and simplifies transaction management through configuration.

Spring also provides support for testing, data source management, allowing easy testing and simplifying the use of data sources.

Next, let's learn how Spring integrates ORM Framework-hibernate.

Kai Tao Spring3 (8.1)-8.1 Overview of ORM Support

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.