Orm

xiaoxiao2021-04-05  233

Orm

Object Relational Mapping, Abbreviation ORM is a technique for solving mutual mismatch between object-oriented and relational data stocks. Simply put, the ORM is automatically permanent in the relational database by using metadata mapped between objects and databases. Essentially is to convert data from one form to another. This also suggests additional overhead; however, if ORM is implemented as an intermediate piece, there will be many opportunities to optimize, and these persistent layers in handwriting do not exist. More importantly, the metadata used to control the conversion needs to provide and manage; however, these spending should be less than the maintenance handwriting; and even if the object database complying with the ODMG specification still requires the class level of metadata. Object - Object / Relation Mapping, Abbreviation ORM, is produced with the development of object-oriented software development methods. Object-oriented development methods are mainstream development methods in the current enterprise application development environment, and the relational database is a mainstream data storage system for permanent storage data in an enterprise-level application environment. Objects and relationship data is the two expressions of business entities, and the business entity appears to be object in memory, which is referred to in the database. There is associated and inheritance relationship between objects in memory, and in the database, relational data cannot directly express multi-related and inheritance relationships. Therefore, the object-relational mapping (ORM) system typically exists in the form of an intermediate, mainly implements mapping of program objects to relational database data. Object-oriented is developed from basic principles (such as coupling, aggregation, packaging), and relational databases are developed from mathematical theory, and there are significant differences in two sets. In order to solve this mismatch, the object relationship mapping technology came into being. Let us start from O / R. The letter O originated from "object" (Object), and R comes from "relational". 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 save the information of the object in the relational database. When you develop an application (not using O / R mapping), you may write a lot of data access layers, used to save, delete, read object information, and so on. You have written a lot of methods in DAL to read object data, change status objects, and the like. These codes are always repeated. If you open your nearest program, look at DAL code, you will definitely see a lot of approximately general mode. In order to save objects, we pass an object, add SQLParameter for the SQLCommand object, corresponding to all attributes and objects, set SQLCommand's CommandText attribute as a stored procedure, and then run SQLCommand. Write these code for each object. In addition, is there a better way? Yes, an O / R mapping is introduced. In essence, an O / R mapping will generate DAL for you. It is better to use O / R mapping with its own written DAL code. You save, delete, read objects with O / R mapping, O / R mapping is responsible for generating SQL, you only need to care about the object. Object Relations Maps are successfully used in different object-oriented persistent layers such as: Torque, OJB, Hibernate, Toplink, Castor JDO, TJDO, etc.

The general ORM includes the following four parts: API for persistent class objects; a language or API is used to specify queries related to class and class properties; a tool for mapping metadata; one technology can make ORM implementation DIRTY CHECKING, LAZY Association Fetching and other optimized operations together with the transaction object. I. The current popular ORM products currently provide a long-lasting framework for the implementation of the persistent layer framework, common: apache ojb (http://db.apache.org/ojb/) Cayenne (http: // ObjectStyle. ORG / CAYENNE /) JAXOR (http://jaxor.sourceforge.net) Hibernate (http://www.hibatis.com) JRELATIONALFRAMEWORK (http://ijf.sourceforge .NET) Mirage (http://itor.cq2.org/EN/oss/mirage/toon) Smyle (http://www.drjava.de/smyle) Toplink (http://otn.oracle.com/products /iars/toplink/index.html) where Toplink is Oracle's commercial products, and others are open source projects. Hibernate's lightweight ORM model has gradually established a leader in the Java ORM architecture, and even replacing complex and cumbersome EJB models have become in fact Java ORM industry standards. Moreover, many of them are toned by J2EE standards and become the standard of the latest EJB 3.0 specification, which is also a powerful testimony of open source projects affecting industrial sector. Second, the object-relational mapping mode From "Public Warehouse Meta Model: Development Guide" Chapter 8 CWM Yuan Warehouse, the UML map of the public warehouse meta-model (CWM) is implemented to the Microsoft SQL Server database mapping It is a method of maping an object hierarchy to a relational structure. Personally, it can be used as a rejected method for storing the ontology file to the relational database. Basic Situation: Public Warehouse Element Model (CWM) is an object management organization (omg) one and data warehouse related meta-model standard, using the object hierarchy of the UML represented by the Objects in the database, due to object-oriented database technology Improvement (theoretical research and commercial applications are not mainstream), so the author of the book tends to use a mature relational database to save - this is also the problem encountered when the body is stored. Method: Save the various elements in the UML model to database mode. Since CWM is a meta model, the example of the model is also a model, which is saved in the form of database data. Use more mature stored procedures in the database to increase development and perform efficiency. 1. Data Type Mapping Mode 1.1 Simple Data Type Mode: Establish a mapping table for simple data types in the UML and relational database to guide mapping. 1.2 Enumeration Data Type Model: Each enumeration type corresponds to a table, only one column (_UMliteral) means an enumeration value.

转载请注明原文地址:https://www.9cbs.com/read-132089.html

New Post(0)