Study on the persistence layer of C + + data (i.)

Source: Internet
Author: User

C++orm framework automatically generates code database

Used Java know SSH framework, especially for database development, Java domain has countless ORM framework, for data persistence layer call, such as Hibernate,ibatis (now renamed MyBatis), TOPLINK,JDO,JPA ... Very convenient and practical.

The students who have used C # also know that it is very convenient to build Microsoft's PetShop layered mode by Codesmith software, to reach the data persistence layer code.

So what we do with C + +, we are also object-oriented programming, in the work of the database needs to be managed. Do we need to write the repetitive code completely by hand?

In particular, I am now using QT, a very standard C + + language.

We hope to develop software quickly and focus on software architecture, control systems, communication systems, file transfer systems, and image processing. Don't want to have too much of a burden on the database. Then we also need a lightweight ORM.

First, pre-search

For my current understanding, I know, now there are a variety of free software, can be implemented automatically generate C + + data persistence layer of code!

1, Qxorm:qxorm is a C + + library used to provide ORM functionality, based on the Qt Qtsql library.

License Agreement: LGPL

Development language: C + +

Operating systems: cross-platform

Qxorm is a C + + library used to provide ORM functionality, based on the Qt Qtsql library. Main features: Persistence:communication with a lot of databases (with 1-1, 1-n, n-1 and n-n relationships) Serialization:bina Ry and XM ...

Full Introduction | Qxorm Home | Qxorm Documentation | Qxorm Download | License Agreement: LGPL

Key Features:

Persistence:communication with a lot of databases (with 1-1, 1-n, n-1 and n-n relationships)

Serialization:binary and XML format

Reflection:access to classes definitions, retrieve properties and call classes methods

Advantages:

Non intrusive:the C + + setting function doesn ' t modified class definition, Qxorm can be used in existing projects

No code generation

No XML mapping file

Classes doesn ' t need to inherit from a ' super object '

Template Meta-programming:no macro hack

Works with Visual C + + in Windows and GCC 4.4.1 on Linux (other platforms would be tested SOON:MAC, phones. .)

Only one file <QxOrm.h> to include in Precompiled-header (need Precompiled-header file to reduce compilation times)

It seems that these networks do not have normal access, the download is more difficult

Can access this, there are all versions of Qxorm, available for download. My page is attached with qxorm_1.2.2.zip available for download.

2. Litesql: is a C + + database persistence framework that supports SQLITE3, MySQL, and PostgreSQL databases.

Official website: http://sourceforge.net/apps/trac/litesql

3, Odb:odb is an open source, support multi-platform, support multi-database C + + ORM framework, can map C + + object database table, make easy database query and operation. ODB supports MySQL, Sqllite, PostgreSQL, Oracle and other databases

Official website: http://www.codesynthesis.com/products/odb/download.xhtml

ODB Support Features

Automatically generate database-supported code (cross-database)

Ability to handle any standard C + + code (no development platform limitations)

Compile the build database form based on the definition of the class (you can configure the compile command in Visual Studio)

The form exists in the form of a standalone SQL file, or embedded in C + + SQL code

Supports object-oriented persistence model and database API (provides easy-to-use database operation methods)

Support for object query language based on expression or type safety

ODB using version control

Support for executing local SQL language

Supports SQL tracing (the Output window can output the currently executing SQL statement in real time)

Cross-platform, providing connection pooling to ensure thread safety

About Mappings

Default mapping of all basic C + + types and std::string

Automatic mapping of C + + enum objects to the database enum type or integral type

Supports mapping blob types to Std::vector<char>

Supports synthetic value types (automatically resolves to multiple fields)

Supports null semantics mapping to smart pointers, such as odb::nullable or boost::optional.

Support for assigning table names to persistent classes

Support for assigning field names to data members

Support for mapping C + + types to database types

Object IDs that support automatic assignment

Support for persistent classes without IDs

Supports read-only/constant data members

Supports the use of custom smart pointers as pointers to Object/view/value

Support for Cache technology (using session)

Specific use can be found in the official ODB manual, here

What is the difference, how to use, pros and cons? I have to get to know it. When I develop this piece, I'll summarize it. I hope members can make their comments.

Second, C + + These ORM framework differences

The previous time to understand the next ORM (Object Relational mapping), and then found the next C + + ORM Framework, found that really very little, mainly in the following several

Name Open source License requires a specific framework support support for QT support boost support for MySQL support support for SQL support.
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::D bo Yes Gpl/commercial Yes, Wt No Yes Yes Yes Yes No No No No No

Litesql uses XML to define the form, and it feels like it's writing support for all libraries into a dynamic link library, so it's huge, QXQRM, Wt::D Bo relies on a particular framework. So considering, the feeling ODB is the most suitable for development.

Reference article:

1. Introduction of a C + + ORM tool ODB (i)

2. Introduction of a C + + ORM tool ODB (ii)

3. C + + ORM Framework Qxorm

Qxorm Usage Records

Qxorm use Record (ii)

Qxorm use Record (iii)

4, other articles are not listed.

Study on the persistence layer of C + + data (i.)

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.