Introduction to ORM Framework

Source: Internet
Author: User

Object Relational Mapping (ORM Object Relational Mapping) provides conceptual, easy-to-understand methods for modeling data. The ORM methodology is based on three core principles: simple: Modeling data in the most basic form. Communication: The database structure is documented in a language that anyone can understand. Accuracy: Create a properly standardized structure based on the data model. Typically, modelers develop information models by collecting information from people who are familiar with the application but are not proficient in data modelers. Modelers must be able to communicate with the data structure at the conceptual level using terminology that non-technical enterprise experts can understand. The modeler must also be able to process the sample data with simple unit analysis information. ORM is specifically designed to improve this connection.

Object-Relational mapping (Object/relation Mapping, or ORM) is a result of the development of object-oriented software development methods. The object-oriented development method is the mainstream development method in the enterprise application development environment, and the relational database is the mainstream data storage system which is stored permanently in the enterprise-level application environment. object and relational data are two representations of business entities, and business entities behave as objects in memory and behave as relational data in the database. There are associations and inheritance relationships between objects in memory, and in a database, relational data cannot directly express many-to-many associations and inheritance relationships.  Therefore, object-relational mapping (ORM) system usually exists in the form of middleware, which mainly realizes the mapping of program object to relational database data. Object-oriented is developed from the basic Principles of software engineering (such as coupling, aggregation, encapsulation), and the relational database is developed from the mathematical theory, and the two sets of theories have significant differences.  In order to solve this mismatch, object-relational mapping technology emerged. Let's start with the O/R. The letter O originates from "object", and R is derived from "relationship" (relational). In almost all programs, there are objects and relational databases. In the business logic layer and the user interface layer, we are object-oriented.  When the object information changes, we need to keep the object's information in the relational database. When you develop an application (do not use O/R Mapping), you may write a lot of data access layer code to save, delete, read object information from the database, and so on. You wrote a lot of ways to read object data, change state objects, and so on in the Dal.  And the code is always repeating itself. If you open your recent program and look at the DAL code, you will definitely see a lot of approximate generic patterns. As an example of how to save an object, you pass in an object, add SqlParameter to the SqlCommand object, correspond all the properties and objects, set the CommandText property of the SqlCommand to the stored procedure, and then run SqlCommand.  Write the code repeatedly for each object. Besides, is there a better way? There, introduce a O/R Mapping. Essentially, an O/R mapping will generate a DAL for you. Instead of writing the DAL code yourself, use the O/R Mapping.  You use O/R mapping to save, delete, read objects, O/R mapping is responsible for generating SQL, you just need to care about the object just fine.  Object Relational mapping is successfully applied in different object-oriented persistence layer products, such as: Torque,ojb,hibernate,toplink,castor JDO, TJDO, etc. The general ORM consists of the following four parts: An API for CRUD operations on persistent class objects; A language or API used to specify queries related to classes and class attributes; A tool that prescribes mapping metadata; a technique that enables an ORM implementation to dirty with a transactional object checking, the lazy as Sociation fetching and other optimization operations.


Introduction to ORM Framework

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.