[odb-announcements] ODB 1.0.0 released

Boris Kolpackov boris at codesynthesis.com
Wed Sep 29 10:13:42 EDT 2010


ODB is an open-source, compiler-based object-relational mapping (ORM)
system for C++. It allows you to persist C++ objects to a relational
database without having to deal with tables, columns, or SQL and
without manually writing any mapping code. For example:

  #pragma db object
  class person

    friend class odb::access;
    person ();

    #pragma db id auto
    unsigned long id_;

    string first_;
    string last_;
    unsigned short age_;

ODB is not a framework. It does not dictate how you should write your
application. Rather, it is designed to fit into your style and 
architecture by only handling C++ object persistence and not 
interfering with any other functionality. As you can see, existing
classes can be made persistent with only a few modifications.

Given the above class, we can perform various database operations with
its objects:

  person john ("John", "Doe", 31);
  person jane ("Jane", "Doe", 29);

  transaction t (db.begin ());

  db.persist (john);
  db.persist (jane);

  result r (db.query<person> (query::last == "Doe" && query::age < 30));
  copy (r.begin (), r.end (), ostream_iterator<person> (cout, "\n"));

  jane.age (jane.age () + 1);
  db.update (jane);

  t.commit ();

The C++ code that performs the conversion between persistent classes
and their database representation is automatically generated by the
ODB compiler. The ODB compiler is a real C++ compiler except that it
produces C++ instead of assembly or machine code. In particular, it is
not an ad-hoc header pre-processor that is only capable of recognizing
a subset of C++. ODB is capable of handling any standard C++ code.

The ODB compiler uses the GCC compiler frontend for C++ parsing and is
implemented using the new GCC plugin architecture. While ODB uses GCC
internally, its output is standard C++ which means that you can use
any C++ compiler to build your application.

ODB is written in portable C++ and you should be able to use it with
any modern C++ compiler. In particular, we have tested this release
on GNU/Linux (x86/x86-64), Windows (x86/x86-64), Mac OS X, and Solaris
(x86/x86-64/SPARC) with GNU g++ 4.2.x-4.5.x, MS Visual C++ 2008 and
2010, and Sun Studio 12. The dependency-free ODB compiler binaries
are available for all of the above platforms. The initial release
supports MySQL as the underlying database. Support for other database
systems is in the works.

More information, documentation, source code, and pre-compiled binaries
are available from:



More information about the odb-announcements mailing list