ODB Features
The following categorized list highlights the main ODB features.
General
- Automatic generation of database support code.
- Ability to handle any standard C++ code.
- Support for C++98/03, C++11, and later standards.
- Optional automatic generation of database schema.
- Generation of database schema as a standalone (combined) SQL file or embedded into C++ code.
- Multi-database support in two flavors: static and dynamic.
- Object-oriented persistence model and database API.
- Expressive and type-safe object query language.
- Support for optimistic concurrency using object versioning.
- Support for native SQL statement execution.
- Support for stored procedure calls.
- Support for bulk database operations (PostgreSQL, MS SQL, and Oracle).
- Support for fine-grained SQL statement execution tracing.
- Cross-platform, thread safe implementation with connection pooling support.
- Low footprint with fine-grained optional feature control; suitable for using on mobile/embedded systems.
Mapping
- Default mapping for all fundamental C++ types,
char[N], andstd::string. - Default mapping for standard containers:
std::vector,std::map, etc. - Automatic mapping of C++98 and C++11 enumerations to database
ENUMtypes or integers. - Ability to map extended database types, such as geospatial types, user-defined types, and collections.
- Support for mapping
BLOBtypes tostd::vector<char>,std::array<char, N>, andchar[N]. - Support for composite (multi-column) value types.
- Support for object sections that allow partitioning of data members of a persistent class into independently loaded and/or updated groups.
- Ability to define persistent classes and composite value types as class template instantiations.
- Support for the
NULLsemantics for simple and composite values with mapping to smart pointers,odb::nullable, orboost::optional. - Ability to assign table names to persistent classes.
- Ability to assign column names to data members.
- Support for automatically-derived SQL name transformations.
- Ability to define database indexes on data members.
- Ability to map C++ types to database types on a per-type and per-member basis.
- Ability to use accessor/modifier functions/expressions to access data members.
- Support for mapping C++ types as other C++ types.
- Support for virtual (imaginary) data members.
- Support for database schemas (database namespaces).
- Support for automatically-assigned object ids.
- Support for persistent classes without object ids.
- Support for composite object ids (composite primary keys).
- Support for read-only/
constdata members. - Ability to use custom smart pointers as object/view/value pointers.
- Support for optional object caching (session), including the ability to provide a custom session implementation.
Database Schema Evolution
- Automatic database schema migration.
- Support for immediate and gradual data migration.
- Soft model changes (ability to work with multiple database versions using the same object model).
Databases
- SQLite runtime
- Supports SQLite 3.3.6 and later.
- For multi-threaded database access SQLite 3.6.18 or later is required.
- Based on the native SQLite3 C API.
- Uses and caches prepared statements.
- Uses shared cache and unlock notifications to support multi-threaded database access.
- Support for attaching additional SQLite databases.
- Support for SQLite incremental
BLOB/TEXTI/O. - Support for mixed auto/manual id assignment.
- Additional type mappings:
TEXT—std::wstring,wchar_t[N](Windows only),QStringBLOB—std::vector<char>,std::array<char, N>,char[N],QByteArrayTEXT,INTEGER—boost::gregorian::date,QDateTEXT,INTEGER—boost::posix_time::time_duration,QTimeTEXT,INTEGER—boost::posix_time::ptime,QDateTime
- PostgreSQL runtime
- Supports PostgreSQL 7.4 and later.
- Based on the native C API (
libpq). - Support for bulk database operations.
- Support for calling stored procedures and functions.
- Uses and caches prepared statements.
- Uses the binary format for sending parameters and receiving results.
- Additional type mappings:
BYTEA—std::vector<char>,std::array<char, N>,char[N],QByteArrayDATE—boost::gregorian::date,QDateTIME—boost::posix_time::time_duration,QTimeTIMESTAMP—boost::posix_time::ptime,QDateTime
- MySQL runtime
- Supports MySQL/MariaDB 5.0.3 and later.
- Based on the native C API (
libmysqlclient). - Support for calling stored procedures.
- Uses and caches prepared statements.
- Support for mixed auto/0 id assignment.
- Additional type mappings:
BLOB,BINARY—std::vector<char>,std::array<char, N>,char[N],QByteArrayDATE—boost::gregorian::date,QDateTIME—boost::posix_time::time_duration,QTimeDATETIME,TIMESTAMP—boost::posix_time::ptime,QDateTime
- Oracle runtime
- Supports Oracle 10.1 and later.
- Based on the native C API (OCI).
- Support for bulk database operations.
- Uses and caches prepared statements.
- Uses streaming for LOB types (
BLOB,CLOB, andNCLOB). - Additional type mappings:
RAW, BLOB—std::vector<char>,std::array<char, N>,char[N],QByteArrayDATE—boost::gregorian::date,boost::posix_time::ptime,QDate,QDateTimeINTERVAL DAY TO SECOND—boost::posix_time::time_duration,QTimeTIMESTAMP—boost::posix_time::ptime,QDateTime
- Microsoft SQL Server runtime
- Supports SQL Server 2005 and later.
- Based on the SQL Server Native Client ODBC driver.
- Supports Windows and Linux.
- Support for bulk database operations.
- Support for calling stored procedures.
- Uses and caches prepared statements.
- Support for
ROWVERSION-based optimistic concurrency. - Uses streaming for long data types.
- Additional type mappings:
NCHAR,NVARCHAR,NTEXT—std::wstring,wchar_t[N],QStringBINARY,VARBINARY,IMAGE—std::vector<char>,std::array<char, N>,char[N],QByteArrayDATE—boost::gregorian::date,QDateTIME—boost::posix_time::time_duration,QTimeDATETIME,SMALLDATETIME,DATETIME2—boost::posix_time::ptime,QDateTimeMONEY,SMALLMONEY—float,double, integer typesUNIQUEIDENTIFIER—GUID
Frameworks
- Optional Boost profile integrates ODB with Boost smart pointers, containers,
and value types:
- Value types:
uuidanddate_timelibraries. - Smart pointers:
boost::shared_ptr,boost::weak_ptr. - Containers:
unordered,optional, andmulti_indexcontainer libraries.
- Value types:
- Optional Qt profile integrates ODB with Qt smart pointers, containers, and
value types:
- Value types:
QString,QUuid,QByteArray,QDate,QTime,QDateTime. - Smart pointers:
QSharedPointer,QWeakPointer. - Containers:
QList,QVector,QLinkedList,QMap,QMultiMap,QSet,QHash,QMultiHash. - Change-tracking equivalents for:
QList. - Support for Qt5 and Qt6.
- Value types:
Relationships
- Support for unidirectional to-one and to-many relationships.
- Support for bidirectional one-to-one, one-to-many, and many-to-many relationships.
- Support for relationships with inverse sides and canonical database schemas.
- Support for eager and lazy loading of object relationships.
Containers
- Built-in support for standard C++98 containers (
vector,list,deque,set,map, etc). - Built-in support for standard C++11 containers (
array, unordered containers, etc). - Support for change-tracking containers for efficient database updates.
- Change-tracking equivalents for:
std::vector,QList. - Ability to persist custom containers.
- Ability to customize container table and column names.
Inheritance
- Support for reuse-style inheritance with the table-per-object mapping.
- Support for polymorphism-style inheritance with the table-per-difference mapping.
- Support for abstract base classes.
Query
- Support for object-based, C++-integrated query expressions.
- Support for database-native SQL
SELECTquery expressions. - Ability to use members of composite value types in query expressions.
- Ability to use members of related objects in query expressions.
- Support for by-value and by-reference binding of query parameters.
- Standard iterator interface for query result access.
- Support for client-cached and progressive (streaming) query results.
- Support for deleting objects matching a query expression.
- Support for prepared queries.
Views
- Support for read-only projections of persistent objects and/or database tables.
- Ability to load a subset of data members from objects or columns from database tables.
- Support for handling results of arbitrary SQL queries, including aggregate queries.
- Ability to join multiple objects and/or tables using relationships or custom join conditions.
- Support for join types (left, right, full, inner, and cross).
- Ability to load multiple objects with a single
SELECTstatement execution.
Customization
- Per-class database operations callbacks.
- Ability to provide custom database persistence code for value types.
- Ability to provide custom
NULLwrappers.
Performance
- Uses prepared statements.
- Caches connections, statements, and buffers.
- Uses low-level native database APIs.
- Zero per-object memory overhead.
- Support for bulk database operations (PostgreSQL, Oracle, and MS SQL Server)