C++的ORM框架,ODB 2.1.0 发布

jopen 12年前

ODB 是一个开源的,支持多平台,支持多数据库的 C++ 的 ORM 框架,可将 C++ 对象数据库表映射,进行轻松的数据库查询和操作。

    Ease of use. ODB automatically generates database conversion
        code from your C++ classes and allows you to manipulate persistent
        objects using a simple, object-oriented database API.

    Concise code. With ODB hiding the details of the underlying
        database, the application logic is written using the natural object
        vocabulary making it simpler and thus easier to read and understand.

    Safety. The ODB object persistence and query APIs are
        statically typed. You use C++ identifiers instead of strings
        to refer to object members and the generated code makes sure
        database and C++ types are compatible. All this helps catch
        programming errors at compile-time rather than at runtime.

    Database portability. Because the database conversion code
        is automatically generated, it is easy to switch from one database
        vendor to another.

    Optimal performance. ODB has been designed for high performance
        and low memory overhead. All the available optimization techniques,
        such as prepared statements and extensive connection, statement,
        and buffer caching, are used to provide the most efficient
        implementation for each database operation. Persistent classes
        have zero per-object memory overhead. There are no hidden "database"
        members that each class must have nor are there per-object data
        structures allocated by ODB.

    Maintainability. Automatic code generation minimizes the
        effort needed to adapt the application to changes in persistent
        classes. The database conversion code is kept separately from
        the class declarations and application logic. This makes the
        application easier to debug and maintain.

ODB 2.1.0 发布,该版本包含很多新特性,包括:

  • 支持通过访问符、修饰符、函数和表达式来访问数据成员
  • 支持虚拟数据成员
  • 可在数据成员上直接定义数据库索引
  • 支持映射扩展数据库类型,例如空间数据、用户自定义类型和集合
  • 更新了 profile 库
  • 通过 Boost profile 库提供对 Uuid 和多索引容器哭的持久化支持
  • 支持 Visual Studio 2012 和 Clang 3.1


  odb::sqlite::database db ("people.db");      person john ("john@doe.org", "John Doe", 31);    person jane ("jane@doe.org", "Jane Doe", 29);      odb::transaction t (db.begin ());      db.persist (john);    db.persist (jane);      typedef odb::query<person> person_query;      for (person& p: db.query<person> (person_query::age < 30));      cerr << p << endl;      jane.age (jane.age () + 1);    db.update (jane);      t.commit ();