| QxOrm 1.4.9 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions
qx::IxPersistable Class Reference
QxDao : QxOrm library database communication used by persistence engine (ORM - Object Relational Mapping)

qx::IxPersistable : common interface (abstract class) for persistents classes using QX_PERSISTABLE_HPP() and QX_PERSISTABLE_CPP() macros More...

`#include <IxPersistable.h>`

Inheritance diagram for qx::IxPersistable:

List of all members.

## Public Member Functions
| IxPersistable ()
virtual | ~IxPersistable ()
virtual long | qxCount (const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL, const QStringList &relation=QStringList())=0
| Return the number of lines in the table (database) mapped to the current C++ class (registered into QxOrm context) and filtered by a user SQL query.
virtual QSqlError | qxCount (long &lCount, const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL, const QStringList &relation=QStringList())=0
| Return the number of lines in the table (database) mapped to the current C++ class (registered into QxOrm context) and filtered by a user SQL query.
virtual QSqlError | qxFetchById (const QVariant &id=QVariant(), const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)=0
| Fetch current instance (retrieve all its properties) mapped to a table in the database (current instance must have a valid id before to be fetched without error, or pass the id to the first parameter of this method)
virtual QSqlError | qxFetchAll (qx::IxPersistableCollection *list=NULL, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)=0
| Fetch a list of objects (retrieve all elements and properties associated) of current type (container registered into QxOrm context) mapped to a table in the database.
virtual QSqlError | qxFetchByQuery (const qx::QxSqlQuery &query, qx::IxPersistableCollection *list=NULL, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL)=0
| Fetch a list of objects (retrieve all elements and properties associated) of current type (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.
virtual QSqlError | qxInsert (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)=0
| Insert current instance into database.
virtual QSqlError | qxUpdate (const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)=0
| Update current instance into database (you can add a user SQL query to the default SQL query builded by QxOrm library)
virtual QSqlError | qxSave (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, qx::dao::save_mode::e_save_mode eSaveRecursiveMode=qx::dao::save_mode::e_none)=0
| Insert (if no exist) or update (if already exist) current instance into database.
virtual QSqlError | qxDeleteById (const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)=0
| Delete current instance from database.
virtual QSqlError | qxDeleteAll (QSqlDatabase *pDatabase=NULL)=0
| Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)
virtual QSqlError | qxDeleteByQuery (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)=0
| Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) and filtered by a user SQL query.
virtual QSqlError | qxDestroyById (const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false)=0
| Delete current instance from database.
virtual QSqlError | qxDestroyAll (QSqlDatabase *pDatabase=NULL)=0
| Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)
virtual QSqlError | qxDestroyByQuery (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)=0
| Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) and filtered by a user SQL query.
virtual QSqlError | qxExecuteQuery (qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL)=0
| 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.
virtual QSqlError | qxExecuteQuery (qx::QxSqlQuery &query, qx::IxPersistableCollection *list=NULL, QSqlDatabase *pDatabase=NULL)=0
| 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.
virtual qx_bool | qxExist (const QVariant &id=QVariant(), QSqlDatabase *pDatabase=NULL)=0
| Search if current instance already exists into database.
virtual qx::QxInvalidValueX | qxValidate (const QStringList &groups=QStringList())=0
| Check if current instance is valid or not.
virtual std::shared_ptr < qx::IxPersistableCollection > | qxNewPersistableCollection (bool bAsList=false) const =0
| Create a new collection smart-pointer to fetch a list of items of current class type.
virtual qx::IxClass * | qxClass () const =0
| Access to introspection engine (or reflection engine) of QxOrm library.
virtual QString | toJson (const QString &format=QString()) const =0
virtual QJsonValue | toJson_ (const QString &format=QString()) const =0
virtual qx_bool | fromJson (const QString &json, const QString &format=QString())=0
virtual qx_bool | fromJson_ (const QJsonValue &json, const QString &format=QString())=0
## Static Public Member Functions
static std::shared_ptr < qx::IxPersistableCollection > | qxFetchAll (const QString &className, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bAsList=false)
static std::shared_ptr < qx::IxPersistableCollection > | qxFetchByQuery (const QString &className, const qx::QxSqlQuery &query, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bAsList=false)
static std::shared_ptr < qx::IxPersistableCollection > | qxExecuteQuery (const QString &className, qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL, bool bAsList=false)

## Detailed Description

qx::IxPersistable : common interface (abstract class) for persistents classes using QX_PERSISTABLE_HPP() and QX_PERSISTABLE_CPP() macros

To use this common interface for persistents classes :
1- inherit your persistent class from qx::IxPersistable ;
2- into your class definition (myClass.h for example), add QX_PERSISTABLE_HPP(myClass) macro ;
3- into your class implementation (myClass.cpp for example), add QX_PERSISTABLE_CPP(myClass) macro.

Note : for a list of objects (qxFetchAll() method or qxFetchByQuery() method), use qx::QxCollection<type_primary_key, std::shared_ptr<my_type>> type. Or just use qx::QxPersistableCollectionHelper<T>::type to retrieve your persistent collection type. A convenient way to fetch a list of objects is to use following static methods qxFetchAll() and qxFetchByQuery() :

    std::shared_ptr<qx::IxPersistableCollection> lst = qx::IxPersistable::qxFetchAll("myClass");
    for (long l = 0; l < lst->_count(); l++)
    { qx::IxPersistable_ptr ptr = lst->_get<qx::IxPersistable_ptr>(l); etc... }

Definition at line 81 of file IxPersistable.h.

## Constructor & Destructor Documentation

qx::IxPersistable::IxPersistable | ( |  | ) |

virtual qx::IxPersistable::~IxPersistable | ( |  | ) | `[virtual]`

## Member Function Documentation

virtual qx_bool qx::IxPersistable::fromJson | ( | const QString & | json,
|  | const QString & | format = `QString()`
| ) |  | `[pure virtual]`

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual qx_bool qx::IxPersistable::fromJson_ | ( | const QJsonValue & | json,
|  | const QString & | format = `QString()`
| ) |  | `[pure virtual]`

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual qx::IxClass* qx::IxPersistable::qxClass | ( |  | ) | const`[pure virtual]`

Access to introspection engine (or reflection engine) of QxOrm library.

Returns:
  Return a qx::IxClass pointer to access to introspection engine (or reflection engine) of QxOrm library, and get some informations about current class (properties, methods, etc...)

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual long qx::IxPersistable::qxCount | ( | const qx::QxSqlQuery & | query = `qx::QxSqlQuery()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | const QStringList & | relation = `QStringList()`
| ) |  | `[pure virtual]`

Return the number of lines in the table (database) mapped to the current C++ class (registered into QxOrm context) and filtered by a user SQL query.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  relation | List of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation)

qx::IxPersistable * p = ...;
p->qxCount(...) execute following SQL query :
SELECT COUNT(*) FROM my_table + XXX_JOINS_XXX + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxCount | ( | long & | lCount,
|  | const qx::QxSqlQuery & | query = `qx::QxSqlQuery()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | const QStringList & | relation = `QStringList()`
| ) |  | `[pure virtual]`

Return the number of lines in the table (database) mapped to the current C++ class (registered into QxOrm context) and filtered by a user SQL query.

Parameters:

  lCount | Output parameter with the number of lines in the table associated to the SQL query
  query | Define a user SQL query added to default SQL query builded by QxOrm library
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  relation | List of relationships keys to be fetched (eager fetch instead of default lazy fetch for a relation)

qx::IxPersistable * p = ...;
p->qxCount(...) execute following SQL query :
SELECT COUNT(*) FROM my_table + XXX_JOINS_XXX + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDeleteAll | ( | QSqlDatabase * | pDatabase = `NULL` | ) | `[pure virtual]`

Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)

Parameters:

  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDeleteAll(...) execute following SQL query :
DELETE FROM my_table
If a soft delete behavior is defined for current class, p->qxDeleteAll(...) execute following SQL query :
UPDATE my_table SET is_deleted='1'

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDeleteById | ( | const QVariant & | id = `QVariant()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bUseExecBatch = `false`
| ) |  | `[pure virtual]`

Delete current instance from database.

Parameters:

  id | Unique id to delete from database (if empty, check id of current instance)
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  bUseExecBatch | If true then use the QSqlQuery::execBatch() method to improve performance deleting a list of instances in database

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDeleteById(...) execute following SQL query :
DELETE FROM my_table WHERE my_id = ?
If a soft delete behavior is defined for current class, p->qxDeleteById(...) execute following SQL query :
UPDATE my_table SET is_deleted='1' WHERE my_id = ?

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDeleteByQuery | ( | const qx::QxSqlQuery & | query,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) and filtered by a user SQL query.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDeleteByQuery(...) execute following SQL query :
DELETE FROM my_table + WHERE my_query...
If a soft delete behavior is defined for current class, p->qxDeleteByQuery(...) execute following SQL query :
UPDATE my_table SET is_deleted='1' + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDestroyAll | ( | QSqlDatabase * | pDatabase = `NULL` | ) | `[pure virtual]`

Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context)

Parameters:

  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDestroyAll(...) execute following SQL query :
DELETE FROM my_table

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDestroyById | ( | const QVariant & | id = `QVariant()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bUseExecBatch = `false`
| ) |  | `[pure virtual]`

Delete current instance from database.

Parameters:

  id | Unique id to delete from database (if empty, check id of current instance)
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  bUseExecBatch | If true then use the QSqlQuery::execBatch() method to improve performance destroying a list of instances in database

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDestroyById(...) execute following SQL query :
DELETE FROM my_table WHERE my_id = ?

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxDestroyByQuery | ( | const qx::QxSqlQuery & | query,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Delete all lines of a table (database) mapped to current C++ class (registered into QxOrm context) and filtered by a user SQL query.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxDestroyByQuery(...) execute following SQL query :
DELETE FROM my_table + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxExecuteQuery | ( | qx::QxSqlQuery & | query,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

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.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxExecuteQuery | ( | qx::QxSqlQuery & | query,
|  | qx::IxPersistableCollection * | list = `NULL`,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

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.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  list | Container to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

static std::shared_ptr<qx::IxPersistableCollection> qx::IxPersistable::qxExecuteQuery | ( | const QString & | className,
|  | qx::QxSqlQuery & | query,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bAsList = `false`
| ) |  | `[static]`

virtual qx_bool qx::IxPersistable::qxExist | ( | const QVariant & | id = `QVariant()`,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Search if current instance already exists into database.

Parameters:

  id | Unique id to check into database (if empty, check id of current instance)
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Return true if element already exists into database; otherwise return false; if an error occurred, qx_bool object contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxExist(...) execute following SQL query :
SELECT * FROM my_table WHERE my_id = ?

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxFetchAll | ( | qx::IxPersistableCollection * | list = `NULL`,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Fetch a list of objects (retrieve all elements and properties associated) of current type (container registered into QxOrm context) mapped to a table in the database.

Parameters:

  list | Container to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
  columns | List of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
  relation | List of relationships keys to fetch (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
std::shared_ptr<qx::IxPersistableCollection> lst = p->qxNewPersistableCollection();
p->qxFetchAll(& lst, ...) execute following SQL query :
SELECT * FROM my_table

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

static std::shared_ptr<qx::IxPersistableCollection> qx::IxPersistable::qxFetchAll | ( | const QString & | className,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bAsList = `false`
| ) |  | `[static]`

virtual QSqlError qx::IxPersistable::qxFetchById | ( | const QVariant & | id = `QVariant()`,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Fetch current instance (retrieve all its properties) mapped to a table in the database (current instance must have a valid id before to be fetched without error, or pass the id to the first parameter of this method)

Parameters:

  id | Unique id to fetch properties from database (if empty, check id of current instance)
  columns | List of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
  relation | List of relationships keys to fetch (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxFetchById(...) execute following SQL query :
SELECT * FROM my_table WHERE my_id = ?

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxFetchByQuery | ( | const qx::QxSqlQuery & | query,
|  | qx::IxPersistableCollection * | list = `NULL`,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`
| ) |  | `[pure virtual]`

Fetch a list of objects (retrieve all elements and properties associated) of current type (container registered into QxOrm context) mapped to a table in the database and filtered by a user SQL query.

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  list | Container to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
  columns | List of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
  relation | List of relationships keys to fetch (eager fetch instead of default lazy fetch for a relation) : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
std::shared_ptr<qx::IxPersistableCollection> lst = p->qxNewPersistableCollection();
p->qxFetchByQuery(my_query, & lst, ...) execute following SQL query :
SELECT * FROM my_table + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

static std::shared_ptr<qx::IxPersistableCollection> qx::IxPersistable::qxFetchByQuery | ( | const QString & | className,
|  | const qx::QxSqlQuery & | query,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bAsList = `false`
| ) |  | `[static]`

virtual QSqlError qx::IxPersistable::qxInsert | ( | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bUseExecBatch = `false`
| ) |  | `[pure virtual]`

Insert current instance into database.

Parameters:

  relation | List of relationships keys to insert in others tables of database : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  bUseExecBatch | If true then use the QSqlQuery::execBatch() method to improve performance inserting a list of instances to database (but doesn't fill the last inserted identifier in the C++ instances)

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxInsert(...) execute following SQL query :
INSERT INTO my_table (my_column_1, my_column_2, etc.) VALUES (?, ?, etc.)

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual std::shared_ptr<qx::IxPersistableCollection> qx::IxPersistable::qxNewPersistableCollection | ( | bool | bAsList = `false` | ) | const`[pure virtual]`

Create a new collection smart-pointer to fetch a list of items of current class type.

Parameters:

  bAsList | If true, returns a list (array) of persistent instances instead of key/value hash-map

Returns:
  Return a new collection smart-pointer to fetch a list of items of current class type

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxSave | ( | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | qx::dao::save_mode::e_save_mode | eSaveRecursiveMode = `qx::dao::save_mode::e_none`
| ) |  | `[pure virtual]`

Insert (if no exist) or update (if already exist) current instance into database.

Parameters:

  relation | List of relationships keys to insert or update in others tables of database : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  eSaveRecursiveMode | Parameter to call qx::dao::save_with_relation_recursive function

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxSave(...) execute following SQL query :
INSERT INTO my_table (my_column_1, my_column_2, etc.) VALUES (?, ?, etc.)
or (if already exist into database) :
UPDATE my_table SET my_column_1 = ?, my_column_2 = ?, etc.

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QSqlError qx::IxPersistable::qxUpdate | ( | const qx::QxSqlQuery & | query = `qx::QxSqlQuery()`,
|  | const QStringList & | columns = `QStringList()`,
|  | const QStringList & | relation = `QStringList()`,
|  | QSqlDatabase * | pDatabase = `NULL`,
|  | bool | bUseExecBatch = `false`
| ) |  | `[pure virtual]`

Update current instance into database (you can add a user SQL query to the default SQL query builded by QxOrm library)

Parameters:

  query | Define a user SQL query added to default SQL query builded by QxOrm library
  columns | List of database table columns (mapped to properties of C++ class) to update (if empty, all columns are updated)
  relation | List of relationships keys to update in others tables of database : use "|" separator to put many relationships keys into this parameter
  pDatabase | Connection to database (you can manage your own connection pool for example, you can also define a transaction, etc.); if NULL, a valid connection for the current thread is provided by qx::QxSqlDatabase singleton class
  bUseExecBatch | If true then use the QSqlQuery::execBatch() method to improve performance updating a list of instances in database

Returns:
  Empty QSqlError object (from Qt library) if no error occurred; otherwise QSqlError contains a description of database error executing SQL query

qx::IxPersistable * p = ...;
p->qxUpdate(...) execute following SQL query :
UPDATE my_table SET my_column_1 = ?, my_column_2 = ?, etc. + WHERE my_query...

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual qx::QxInvalidValueX qx::IxPersistable::qxValidate | ( | const QStringList & | groups = `QStringList()` | ) | `[pure virtual]`

Check if current instance is valid or not.

Parameters:

  groups | List of groups to check (defined into QxValidator module for current class)

Returns:
  Return list of invalid values (if empty, current instance is valid)

For more details about QxValidator module : https://www.qxorm.com/qxorm_en/faq.html#faq_250

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QString qx::IxPersistable::toJson | ( | const QString & | format = `QString()` | ) | const`[pure virtual]`

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

virtual QJsonValue qx::IxPersistable::toJson_ | ( | const QString & | format = `QString()` | ) | const`[pure virtual]`

Implemented in qx::QxPersistableCollection< Key, Value, T >, and qx::QxPersistableList< T >.

The documentation for this class was generated from the following file:

- C:/Dev/_Perso/QxOrm/include/QxDao/IxPersistable.h