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, TR1, and C++11.
- 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 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
. - Automatic mapping of C++98 and C++11 enumerations to database
ENUM
types or integers. - Ability to map extended database types, such as geospatial types, user-defined types, and collections.
- Support for mapping
BLOB
types 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
NULL
semantics 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 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/
const
data 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
- MySQL runtime
- Supports MySQL/MariaDB 5.0.3 and later.
- Based on the native C API (
libmysqlclient
). - Support for calling MySQL stored procedures.
- Uses and caches prepared statements.
- Additional type mappings:
BLOB
,BINARY
—std::vector<char>
,std::array<char, N>
,char[N]
,QByteArray
DATE
—boost::gregorian::date
,QDate
TIME
—boost::posix_time::time_duration
,QTime
DATETIME
,TIMESTAMP
—boost::posix_time::ptime
,QDateTime
- 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.
- Additional type mappings:
TEXT
—std::wstring
,wchar_t[N]
(Windows only),QString
BLOB
—std::vector<char>
,std::array<char, N>
,char[N]
,QByteArray
TEXT
,INTEGER
—boost::gregorian::date
,QDate
TEXT
,INTEGER
—boost::posix_time::time_duration
,QTime
TEXT
,INTEGER
—boost::posix_time::ptime
,QDateTime
- PostgreSQL runtime
- Supports PostgreSQL 7.4 and later.
- Based on the native C API (
libpq
). - 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]
,QByteArray
DATE
—boost::gregorian::date
,QDate
TIME
—boost::posix_time::time_duration
,QTime
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]
,QByteArray
DATE
—boost::gregorian::date
,boost::posix_time::ptime
,QDate
,QDateTime
INTERVAL DAY TO SECOND
—boost::posix_time::time_duration
,QTime
TIMESTAMP
—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 GNU/Linux.
- Support for bulk database operations.
- Support for calling SQL Server 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]
,QString
BINARY
,VARBINARY
,IMAGE
—std::vector<char>
,std::array<char, N>
,char[N]
,QByteArray
DATE
—boost::gregorian::date
,QDate
TIME
—boost::posix_time::time_duration
,QTime
DATETIME
,SMALLDATETIME
,DATETIME2
—boost::posix_time::ptime
,QDateTime
MONEY
,SMALLMONEY
—float
,double
, integer typesUNIQUEIDENTIFIER
—GUID
Frameworks
- Optional Boost profile integrates ODB with Boost smart pointers, containers,
and value types:
- Value types:
uuid
anddate_time
libraries. - Smart pointers:
boost::shared_ptr
,boost::weak_ptr
. - Containers:
unordered
,optional
, andmulti_index
container 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 Qt4 and Qt5.
- 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 to minimize database load.
- 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-oriented, C++-integrated query expressions.
- Support for database-native SQL
SELECT
query 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
SELECT
statement execution.
Customization
- Per-class database operations callbacks.
- Ability to provide custom database persistence code for value types.
- Ability to provide custom
NULL
wrappers.
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 (Oracle and SQL Server)