QxOrm  1.5.0
C++ Object Relational Mapping library

Provide template functions to map C++ class registered into QxOrm context with table database (ORM - Object Relational Mapping) More...

#include <QtSql/qsqldatabase.h>
#include <QtSql/qsqlquery.h>
#include <QtSql/qsqlrecord.h>
#include <QtSql/qsqlfield.h>
#include <QtSql/qsqlerror.h>
#include <QtSql/qsqldriver.h>
#include <QxCommon/QxBool.h>
#include <QxDao/QxSoftDelete.h>
#include <QxDao/QxDaoPointer.h>
#include <QxDao/QxSqlQuery.h>
#include <QxDao/QxSqlSaveMode.h>

Go to the source code of this file.

Namespaces

namespace  qx
 

Root namespace for all QxOrm library features.


namespace  qx::dao
 

Database communication used by persistence engine (ORM - Object Relational Mapping)


namespace  qx::dao::detail
 

Internal helper tools for qx::dao namespace.


Functions

template<class T >
long qx::dao::count (const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
 Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::count (long &lCount, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
 Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::count_with_relation (long &lCount, const QStringList &relation, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL)
 Return the number of lines in the table (database) mapped to the C++ class T (registered into QxOrm context) and filtered by a user SQL query (with possibility to add relations to SQL query)
template<class T >
QSqlError qx::dao::insert (T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Insert an element or a list of elements into database.
template<class T >
QSqlError qx::dao::save (T &t, QSqlDatabase *pDatabase=NULL)
 Insert (if no exist) or update (if already exist) an element or a list of elements into database.
template<class T >
QSqlError qx::dao::delete_by_id (T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Delete a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered into QxOrm context)
template<class T >
QSqlError qx::dao::destroy_by_id (T &t, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Destroy a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered into QxOrm context), even if a soft delete behavior is defined for class T.
template<class T >
QSqlError qx::dao::delete_all (QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context)
template<class T >
QSqlError qx::dao::destroy_all (QSqlDatabase *pDatabase=NULL)
 Destroy all lines of a table (database) mapped to a C++ class T (registered into QxOrm context), even if a soft delete behavior is defined for class T.
template<class T >
QSqlError qx::dao::delete_by_query (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
 Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::destroy_by_query (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)
 Destroy all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, even if a soft delete behavior is defined for class T.
template<class T >
QSqlError qx::dao::create_table (QSqlDatabase *pDatabase=NULL)
 Create a table into database (with all columns) mapped to a C++ class T (registered into QxOrm context) : be careful, this function can be used only with a SQLite database to create examples or prototypes; For other databases, it is recommended to use QxEntityEditor application or to manage the database schema with an external tool provided by the SGBD (SQLite Manager for SQLite, pgAdmin for PostgreSQL, MySQL Workbench for MySQL, etc...)
template<class T >
qx_bool qx::dao::exist (T &t, QSqlDatabase *pDatabase=NULL)
 Search if an element (or list of elements) already exists into database.
template<class T >
QSqlError qx::dao::fetch_by_id_with_relation (const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database (t must have a valid id before to be fetched without error)
template<class T >
QSqlError qx::dao::fetch_by_id_with_relation (const QStringList &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database (t must have a valid id before to be fetched without error)
template<class T >
QSqlError qx::dao::fetch_by_id_with_all_relation (T &t, QSqlDatabase *pDatabase=NULL)
 Fetch an object t (retrieve all its properties and relationships) of type T (registered into QxOrm context) mapped to a table in the database (t must have a valid id before to be fetched without error)
template<class T >
QSqlError qx::dao::fetch_all_with_relation (const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database.
template<class T >
QSqlError qx::dao::fetch_all_with_relation (const QStringList &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database.
template<class T >
QSqlError qx::dao::fetch_all_with_all_relation (T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties + all relationships associated) of type T (container registered into QxOrm context) mapped to a table in the database.
template<class T >
QSqlError qx::dao::fetch_by_query_with_relation (const QString &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::fetch_by_query_with_relation (const QStringList &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::fetch_by_query_with_all_relation (const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Fetch a list of objects (retrieve all elements and properties + all relationships associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::insert_with_relation (const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Insert an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::insert_with_relation (const QStringList &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Insert an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::insert_with_all_relation (T &t, QSqlDatabase *pDatabase=NULL)
 Insert an element and all its relationships (or a list of elements + all relationships) into database.
template<class T >
QSqlError qx::dao::update_with_relation (const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::update_by_query_with_relation (const QString &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and its relationships (or a list of elements + relationships) into database (adding a user SQL query to the default SQL query builded by QxOrm library)
template<class T >
QSqlError qx::dao::update_with_relation (const QStringList &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::update_by_query_with_relation (const QStringList &relation, const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and its relationships (or a list of elements + relationships) into database (adding a user SQL query to the default SQL query builded by QxOrm library)
template<class T >
QSqlError qx::dao::update_with_all_relation (T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and all its relationships (or a list of elements + all relationships) into database.
template<class T >
QSqlError qx::dao::update_by_query_with_all_relation (const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Update an element and all its relationships (or a list of elements + all relationships) into database (adding a user SQL query to the default SQL query builded by QxOrm library)
template<class T >
QSqlError qx::dao::save_with_relation (const QString &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Insert (if no exist) or update (if already exist) an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::save_with_relation (const QStringList &relation, T &t, QSqlDatabase *pDatabase=NULL)
 Insert (if no exist) or update (if already exist) an element and its relationships (or a list of elements + relationships) into database.
template<class T >
QSqlError qx::dao::save_with_all_relation (T &t, QSqlDatabase *pDatabase=NULL)
 Insert (if no exist) or update (if already exist) an element and all its relationships (or a list of elements + all relationships) into database.
template<class T >
QSqlError qx::dao::save_with_relation_recursive (T &t, qx::dao::save_mode::e_save_mode eSaveMode=qx::dao::save_mode::e_check_insert_or_update, QSqlDatabase *pDatabase=NULL, qx::QxSqlRelationParams *pRelationParams=NULL)
 Insert (if no exist) or update (if already exist) recursively an element and all levels of relationships (or a list of elements + all levels of relationships) into database, useful to save a tree structure for example.
template<class T >
QSqlError qx::dao::fetch_by_id (T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
 Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database (t must have a valid id before to be fetched without error)
template<class T >
QSqlError qx::dao::fetch_all (T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database.
template<class T >
QSqlError qx::dao::fetch_by_query (const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList())
 Fetch a list of objects (retrieve all elements and properties associated) of type T (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
template<class T >
QSqlError qx::dao::update (T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList(), bool bUseExecBatch=false)
 Update an element or a list of elements into database.
template<class T >
QSqlError qx::dao::update_by_query (const qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL, const QStringList &columns=QStringList(), bool bUseExecBatch=false)
 Update an element or a list of elements into database (adding a user SQL query to the default SQL query builded by QxOrm library)
template<class T >
QSqlError qx::dao::update_optimized (qx::dao::ptr< T > &ptr, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Update only modified fields/properties of an element or a list of elements into database (using is dirty pattern and qx::dao::ptr<T> smart-pointer)
template<class T >
QSqlError qx::dao::update_optimized_by_query (const qx::QxSqlQuery &query, qx::dao::ptr< T > &ptr, QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)
 Update only modified fields/properties of an element or a list of elements into database (using is dirty pattern and qx::dao::ptr<T> smart-pointer), adding a user SQL query to the default SQL query builded by QxOrm library.
template<class T >
QSqlError qx::dao::execute_query (qx::QxSqlQuery &query, T &t, QSqlDatabase *pDatabase=NULL)
 Execute a custom SQL query or a stored procedure, all columns that can be mapped to the instance of type T will be fetched automatically.
template<class T >
void qx::dao::on_before_insert (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback before inserting an object into database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_before_update (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback before updating an object into database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_before_delete (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback before deleting an object into database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_before_fetch (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback before fetching an object from database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_after_insert (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback after inserting an object into database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_after_update (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback after updating an object into database (here is an example using QxOrm Trigger)
template<class T >
void qx::dao::on_after_delete (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback after deleting an object into database (here is an example using QxOrm trigger)
template<class T >
void qx::dao::on_after_fetch (T *t, qx::dao::detail::IxDao_Helper *dao)
 Callback after fetching an object from database (here is an example using QxOrm trigger)

Detailed Description

Provide template functions to map C++ class registered into QxOrm context with table database (ORM - Object Relational Mapping)

Author:
Lionel Marty

Definition in file QxDao.h.