Basic understanding of ORM Framework

Source: Internet
Author: User

(The following is mainly used for their own life records, do not like to spray)

From work to now also more than a year, but last Friday, the old shouted at me, asked me a sentence: "I'm going to let you help me find some information on the weekend, you know ORM?" ”

At that time, I was directly stunned, because at that time I completely did not understand the ORM of the concepts of the concept of a few words (although it was certainly used before, and also read the corresponding implementation code)!

After a weekend of searching for some information, it feels like the main ORM frameworks they're talking about are the following

1.NHibernate

Mention NHibernate, I believe that everyone is not unfamiliar, nhibernate from a very good Java-based Hibernate relationship persistence tool, it from the database to persist from the bottom. NET object to the relational database, NHibernate for us to do all this, instead of writing SQL statements to manipulate database objects, the code is only associated with the object, Nhibernat automatically generate SQL statements, And make sure that objects are submitted to the correct tables and fields. Massively reduces the time it takes to manually use SQL and ADO to process data during development. NHibernate can help eliminate or wrap the SQL code for a particular database and convert the result set from a table representation to a series of objects. NHibernate in the form of an XML file configuration, each entity class will correspond to a mapping file

Advantages:
1. A complete ORM framework.
NHibernate provides a more complete encapsulation of the database structure, which maps the database schema to a more complete object model, supports encapsulation, continues the mechanism, has a strong function, and is more flexible than the general ORM.
developers can manipulate databases exactly as they are in the object model.
2. Automatic code generation, reduce the development of code and SQL, so that developers get rid of open sql,ado.net and transactions, caches and other underlying.
The nhibernate O/R mapping implements the mapping between PO and database tables, as well as the automatic generation and execution of SQL. Programmers often simply define the mapping of a PO to a database table to complete the persistence layer operation through the method provided by NHibernate. Programmers do not even need to be proficient in SQL, and NHibernate automatically generates the corresponding SQL based on the stored logic and calls the ADO. NHibernate has tools to generate the PO class directly from the database schema, or to automatically generate the configuration file by adding the attribute property in the code.
all of this reduces development effort.
3. Good documentation support.
NHibernate's code readability and documentation are better.
Disadvantages:
1. More complex, the learning curve is large.
2. There is a high requirement for the database schema. NHibernate need database has good design and relatively perfect constraints.
3. Not suitable for statistical query system. For multi-table checking, complex SQL implementations are more complex and may require additional scenarios.
4. Some XML configuration is required.

Official Address http://www.nhibernate.org/

2.Castle ActiveRecord

ActiveRecord is a subproject in castle, and the current version is RC1. It is also a very good persistence layer framework that encapsulates nhibernate at the bottom, instead of a configuration file with attribute, so you don't have to write complex configuration files like NHibernate.

The Castle ActiveRecord Framework is an ORM framework based on. NET, which implements the ActiveRecord design pattern. It itself is based on NHibernate, but encapsulates most of the chores details of nhibernate, for classes that need to be persisted, simply inherit from the Activerecordbase class and give the property in the class the correct Attribute, Without writing the chores mapping file. For large systems with complex database logic, Castle project recommends still using NHibernate as an ORM, and for operations such as large-volume migrations of database data, backups, and so on, Castle project does not recommend using any ORM mechanism for direct use of ADO.

Advantages:

The success of the 1.Active record relies on two factors: simplicity and framework. The Active record concept is very simple to understand, but it still requires a lot of code if implemented manually.

Writing and maintaining each class requires a lot of code, but this is only the minimum requirement, because you might also want to consider adding one or more data migration objects (DTOS) for each class or data table.

Disadvantages:

2. Theoretically, an additional layer exists between the object model and the data schema, often called the data Mapper, in development. In the active record, we can integrate the layer directly into the object, but as this layer becomes more complex, maintenance costs are increasing.

Another issue with the Active record is the binding between the object and the data table design. If you have to modify the database, modify the object model of the active record and all related code at the same time

3.ibatis.net

Ibatis.net is divided into Datamapper and dataaccess two parts, it should be said that Datamapper is the core of this framework, datamapper using XML files to achieve from the entity to the SQL statements mapping, learning is very simple, After using Datamapper, we are free to use SQL statements or stored procedures; DataAccess allows us to manipulate data through a simple interface without having to understand the details of the underlying implementation

Website address: http://ibatis.apache.org/

4.MyBatis

The predecessor of MyBatis is IBatis. is a data persistence layer (ORM) framework. The term ibatis is derived from the combination of "Internet" and "Abatis" and is a Java-based persistence layer framework. Ibatis provides a durable layer framework that includes SQL maps and Data Access Objects (DAO)

Connection to File Source:

Http://www.cnblogs.com/zhaoyx/articles/1896638.html

Http://www.cnblogs.com/HeroBeast/archive/2010/10/10/1847353.html

Open source China's summary of C#orm framework

Http://www.oschina.net/project/tag/126/orm?sort=view&lang=194&os=0

Basic understanding of 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.