(i)
Some time ago to understand the next ORM (object-relational mapping), and then find the next C + + ORM Framework, found really very few, mainly on the following
name |
Open Source |
License |
specific framework support is required |
Support QT |
Support Boost |
support MySQL |
Support PostgreSQL |
Support SQLite |
supports XML |
Support Oracle |
support for MSSQL Server |
Support ODBC |
Support 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::D bo |
Yes |
Gpl/commercial |
Yes, Wt |
No |
Yes |
Yes |
Yes |
Yes |
No |
No |
No |
No |
No |
Litesql uses XML to define a form, and it feels like it's writing all of the library's support into a dynamic link library, so it's huge, QXQRM, Wt::D Bo is dependent on a particular framework. So in general, feeling ODB is the most suitable for development. Website Transmission Door
ODB support features automatically generate database-supported code (CROSS-DATABASE) to handle any standard C + + code (no development platform limitations) Compile the Build database form (you can configure compilation commands in Visual Studio) as a separate SQL file or embed C + + based on the class definition The form of SQL code that supports object-oriented persistence models and database APIs (providing Easy-to-use database operations methods) supports object query languages based on expressions or type ODB using versioning support to execute native SQL languages Supports SQL tracing (Output window can output the currently executing SQL statement) across platforms, providing connection pooling to ensure thread safety
About mapping default mappings for all basic C + + types and std::string automatically map enumerated objects of C + + to the database enum type or integer support mapping blob types to std::vector<char> support synthetic value types (automatically parse into multiple fields) Supports the mapping of NULL semantics to smart pointers, such as odb::nullable or boost::optional. Supports assigning table names to persistent classes support assigning field names to data members support mapping C + + type to database type support for automatic assignment object IDs support for persistent classes with no IDs support read-only/constant data members support using a custom smart pointer as a pointer to a object/view/value Support Cache Technology (using session)
Specific use can see the official ODB Handbook here
Write a small example, fully feel the next ODB (1.7.0 version). Overall it's still good, but it's a big problem to apply to actual projects.
The first is that the Federated primary key is not supported, and there is no check constraint, UNIQUE constraint, which is officially acknowledged.
Although delayed loading (lazyload) is provided to improve efficiency, it is inconvenient to use
The query is not flexible and can only be set after the where the query conditions, such as query presence (select EXISTS), query number (select COUNT) must define a view to implement, it is troublesome
Bulk deletion is slow and inflexible. The advanced point only provides the deletion by query condition, but this is far from enough, although the interface that executes SQL is opened, but this destroys the original intention of ORM tool design, also brings trouble for later maintenance.
There is a trigger corresponding function (ie, software implementation), provides callback (callback), support triggers commonly used events, delete before and after, add before and after. But I tried to add a delete trigger another table Data deletion compilation failed, I don't know why
No stored procedures, cursors corresponding to the software implementation
The following is the result of the attachment source code:
Attachment Download:
http://dl.dbank.com/c07l5w5k7x
(Need to go to the official website to download ODB compiled and added to the VC directory, recommend the use of VS2008SP1 above version of the IDE, or use boost library, because the need for smart pointers)