Introduces a C ++ ORM tool ODB

Source: Internet
Author: User
Tags ibm db2 mssql server

Source: http://blog.csdn.net/CAICHAO1234/article/details/8997051

(1)

I learned about ORM (Object link ing) some time ago, and then I found the C ++ ORM framework. I found that there are very few such frameworks:

Name Open Source License Requires support from specific frameworks Supports QT Boost supported Support for MySQL Support for PostgreSQL SQLite supported Supports XML Support for Oracle Support for MSSQL Server Supports ODBC Support for IBM DB2
Litesql Yes BSD No Yes   Yes Yes Yes          
ODB Yes GPL/Other No Yes Yes Yes Yes Yes   Yes      
Qxorm Yes Lgpl Yes, QT Yes Yes Yes Yes Yes   Yes Yes Yes Yes
Wt: DBO Yes GPL/commercial Yes, WT No Yes Yes Yes Yes No No No No No

Litesql uses XML to define the form, and it seems that it writes the support of all databases to a dynamic link library, so it is relatively large, qxqrm, wt :: DBO depends on a specific framework. Therefore, we feel that ODB is the most suitable for development. Official website portal

ODB support features

  • Automatically generate code supported by the database (cross-database)
  • Ability to process any standard C ++ code (no development platform restrictions)
  • Compile and generate database forms based on class definitions (you can configure compilation commands in Visual Studio)
  • A form exists in the form of an independent SQL file or an SQL code embedded in C ++.
  • Supports object-oriented persistence models and database APIs (provides easy-to-use database operation methods)
  • Supports expressions or Type-safe object query languages
  • ODB uses Version Control
  • Supports local SQL Execution
  • Supports SQL tracking (the output window can output the currently executed SQL statements in real time)
  • Cross-platform connection pool to ensure thread security

About ing

  • By default, all basic C ++ types and STD: string are mapped.
  • Automatically maps the C ++ enumerated object to the enum type or Integer type of the database.
  • Supports blob ing blob to STD: vector <char>
  • Supports merging value types (automatically parsed into multiple fields)
  • Supports null semantic ing to smart pointers, such as ODB: nullable or boost: Optional.
  • Allows you to allocate table names to persistent classes.
  • Field names can be allocated to data members.
  • Supports ing c ++ type to Database Type
  • ID of an object that supports automatic assignment
  • Supports persistence classes without IDs
  • Support read-only/constant data members
  • Allows you to use custom smart pointers as pointers to objects, views, and values.
  • Support for Cache Technology (using session)

For more information, see the ODB manual.

I wrote a small example to fully understand the ODB (version 1.7.0 ). In general, it is good, but the problem is still relatively large when applied to actual projects.

First, the Union primary key is not supported, and there are no check and unique constraints. This is officially recognized.

Although lazyload is provided to improve efficiency, it is not convenient to use it.

The query is not flexible. You can only set the query conditions in the part after the WHERE clause. For example, you must define a view for the existence of a query (select exists) and the number of queries (select count). This is really troublesome.

Batch deletion is slow and inflexible. At the advanced level, only deletion based on query conditions is provided, but this is far from enough. Although the SQL Execution interface is opened, the original design of the ORM tool is damaged, it also brings trouble for future maintenance.

Has the function (software implementation) corresponding to the trigger, provides callback, supports common events of the trigger, before and after deletion, and new before and after addition. However, I tried to add a deletion to trigger another table's data deletion and compilation failed. Why?

No software implementation for stored procedures and cursors

 

The following is the running result of the source code of the Attachment:

Attachment download:

Http://dl.dbank.com/c07l5w5k7x

(You need to download the ODB compilation on the official website and add it to the VC directory. We recommend that you use the IDE of vs2008sp1 or later or the boost library because smart pointers are required)

Related Article

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.