QxOrm
1.5.0
C++ Object Relational Mapping library
|
qx::QxModelService<T, S> : provides an easy way to connect your model to the QxService module (all queries are executed over network using client/server communication) More...
#include <QxModelService.h>
Public Types | |
typedef qx::QxModel< T, B > ::type_ptr | type_ptr |
typedef qx::QxModel< T, B > ::type_primary_key | type_primary_key |
typedef qx::QxModel< T, B > ::type_collection | type_collection |
typedef std::shared_ptr < type_collection > | type_collection_ptr |
typedef B | type_base_class |
Public Member Functions | |
QxModelService (QObject *parent=0) | |
QxModelService (qx::IxModel *other, QObject *parent) | |
virtual | ~QxModelService () |
virtual long | qxCount (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. | |
virtual QSqlError | qxCount (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. | |
virtual QSqlError | qxFetchById (const QVariant &id, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Clear the model and fetch an object (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database. | |
virtual QSqlError | qxFetchAll (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Clear the model and 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. | |
virtual QSqlError | qxFetchByQuery (const qx::QxSqlQuery &query, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Clear the model and 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. | |
virtual QSqlError | qxFetchRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Get an item in the model at line row and fetch all its properties mapped to a table in the database, then all views attached to this model are automatically updated. | |
virtual QSqlError | qxInsert (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false) |
Insert all items in the model into database. | |
virtual QSqlError | qxInsertRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Insert an item of the model at line row into database. | |
virtual QSqlError | qxUpdate (const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bUseExecBatch=false) |
Update all items in the model into database. | |
virtual QSqlError | qxUpdateRow (int row, const qx::QxSqlQuery &query=qx::QxSqlQuery(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Update an item of the model at line row into database. | |
virtual QSqlError | qxSave (const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Save all items (insert or update) in the model into database. | |
virtual QSqlError | qxSaveRow (int row, const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL) |
Save an item of the model at line row into database. | |
virtual QSqlError | qxDeleteById (const QVariant &id, QSqlDatabase *pDatabase=NULL) |
Delete a line of a table (database) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model. | |
virtual QSqlError | qxDeleteAll (QSqlDatabase *pDatabase=NULL) |
Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model. | |
virtual QSqlError | qxDeleteByQuery (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, if no error occurred then you should refresh the model. | |
virtual QSqlError | qxDeleteRow (int row, QSqlDatabase *pDatabase=NULL) |
Delete in database the item at line row in the model, if no error occurred then you should remove row from the model. | |
virtual QSqlError | qxDestroyById (const QVariant &id, QSqlDatabase *pDatabase=NULL) |
Delete a line of a table (even if a logical delete is defined) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model. | |
virtual QSqlError | qxDestroyAll (QSqlDatabase *pDatabase=NULL) |
Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model. | |
virtual QSqlError | qxDestroyByQuery (const qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL) |
Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model. | |
virtual QSqlError | qxDestroyRow (int row, QSqlDatabase *pDatabase=NULL) |
Delete in database (even if a logical delete is defined) the item at line row in the model, if no error occurred then you should remove row from the model. | |
virtual QSqlError | qxExecuteQuery (qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL) |
virtual qx_bool | qxExist (const QVariant &id, QSqlDatabase *pDatabase=NULL) |
virtual qx::QxInvalidValueX | qxValidate (const QStringList &groups=QStringList()) |
virtual qx::QxInvalidValueX | qxValidateRow (int row, const QStringList &groups=QStringList()) |
Protected Member Functions | |
virtual QVariant | getRelationshipValues_Helper (int row, const QString &relation, bool bLoadFromDatabase, const QString &sAppendRelations) |
qx::QxModelService<T, S> : provides an easy way to connect your model to the QxService module (all queries are executed over network using client/server communication)
T template parameter is a persistent class registered into QxOrm context S template parameter is a service class generated by QxEntityEditor (or your own service class providing all methods)
Definition at line 58 of file QxModelService.h.
typedef B qx::QxModelService< T, S, B >::type_base_class |
Reimplemented from qx::QxModel< T, B >.
Definition at line 67 of file QxModelService.h.
typedef qx::QxModel<T, B>::type_collection qx::QxModelService< T, S, B >::type_collection |
Reimplemented from qx::QxModel< T, B >.
Definition at line 65 of file QxModelService.h.
typedef std::shared_ptr<type_collection> qx::QxModelService< T, S, B >::type_collection_ptr |
Definition at line 66 of file QxModelService.h.
typedef qx::QxModel<T, B>::type_primary_key qx::QxModelService< T, S, B >::type_primary_key |
Reimplemented from qx::QxModel< T, B >.
Definition at line 64 of file QxModelService.h.
typedef qx::QxModel<T, B>::type_ptr qx::QxModelService< T, S, B >::type_ptr |
Reimplemented from qx::QxModel< T, B >.
Definition at line 63 of file QxModelService.h.
qx::QxModelService< T, S, B >::QxModelService | ( | QObject * | parent = 0 | ) | [inline] |
Definition at line 71 of file QxModelService.h.
qx::QxModelService< T, S, B >::QxModelService | ( | qx::IxModel * | other, |
QObject * | parent | ||
) | [inline] |
Definition at line 72 of file QxModelService.h.
virtual qx::QxModelService< T, S, B >::~QxModelService | ( | ) | [inline, virtual] |
Definition at line 73 of file QxModelService.h.
virtual QVariant qx::QxModelService< T, S, B >::getRelationshipValues_Helper | ( | int | row, |
const QString & | relation, | ||
bool | bLoadFromDatabase, | ||
const QString & | sAppendRelations | ||
) | [inline, protected, virtual] |
Reimplemented from qx::QxModel< T, B >.
Definition at line 381 of file QxModelService.h.
virtual long qx::QxModelService< T, S, B >::qxCount | ( | const qx::QxSqlQuery & | query = qx::QxSqlQuery() , |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
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.
query | Define a user SQL query added to default SQL query builded by QxOrm library (optional 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 75 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxCount | ( | long & | lCount, |
const qx::QxSqlQuery & | query = qx::QxSqlQuery() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
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.
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 (optional 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 82 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteAll | ( | QSqlDatabase * | pDatabase = NULL | ) | [inline, virtual] |
Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 262 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteById | ( | const QVariant & | id, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete a line of a table (database) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.
id | Row id to be deleted from database |
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 249 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteByQuery | ( | const qx::QxSqlQuery & | query, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete all lines of a table (database) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 270 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDeleteRow | ( | int | row, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete in database the item at line row in the model, if no error occurred then you should remove row from the model.
row | Delete in database the item in the model at line row |
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 278 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyAll | ( | QSqlDatabase * | pDatabase = NULL | ) | [inline, virtual] |
Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context), if no error occurred then you should clear the model.
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 302 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyById | ( | const QVariant & | id, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete a line of a table (even if a logical delete is defined) mapped to a C++ object of type T (registered into QxOrm context), if no error occurred then you should remove row from the model.
id | Row id to be deleted from database |
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 289 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyByQuery | ( | const qx::QxSqlQuery & | query, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete all lines of a table (even if a logical delete is defined) mapped to a C++ class T (registered into QxOrm context) and filtered by a user SQL query, if no error occurred then you should refresh the model.
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 310 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxDestroyRow | ( | int | row, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Delete in database (even if a logical delete is defined) the item at line row in the model, if no error occurred then you should remove row from the model.
row | Delete in database the item in the model at line row |
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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 318 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxExecuteQuery | ( | qx::QxSqlQuery & | query, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Reimplemented from qx::QxModel< T, B >.
Definition at line 329 of file QxModelService.h.
virtual qx_bool qx::QxModelService< T, S, B >::qxExist | ( | const QVariant & | id, |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Reimplemented from qx::QxModel< T, B >.
Definition at line 346 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchAll | ( | const QStringList & | relation = QStringList() , |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Clear the model and 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.
relation | List of relationships keys to be fetched (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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 111 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchById | ( | const QVariant & | id, |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Clear the model and fetch an object (retrieve all its properties) of type T (registered into QxOrm context) mapped to a table in the database.
id | Row id to be fetched (retrieve all properties from database) |
relation | List of relationships keys to be fetched (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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 90 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchByQuery | ( | const qx::QxSqlQuery & | query, |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Clear the model and 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.
query | Define a user SQL query added to default SQL query builded by QxOrm library |
relation | List of relationships keys to be fetched (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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 128 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxFetchRow | ( | int | row, |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Get an item in the model at line row and fetch all its properties mapped to a table in the database, then all views attached to this model are automatically updated.
row | Get an item in the model at line row |
relation | List of relationships keys to be fetched (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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 145 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxInsert | ( | const QStringList & | relation = QStringList() , |
QSqlDatabase * | pDatabase = NULL , |
||
bool | bUseExecBatch = false |
||
) | [inline, virtual] |
Insert all items in the model into database.
relation | List of relationships keys to be inserted 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 (optional parameter) |
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) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 162 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxInsertRow | ( | int | row, |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Insert an item of the model at line row into database.
row | Insert an item in the model at line row |
relation | List of relationships keys to be inserted 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 177 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxSave | ( | const QStringList & | relation = QStringList() , |
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Save all items (insert or update) in the model into database.
relation | List of relationships keys to be inserted 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 220 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxSaveRow | ( | int | row, |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Save an item of the model at line row into database.
row | Save an item (insert or update) in the model at line row |
relation | List of relationships keys to be inserted 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 235 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxUpdate | ( | const qx::QxSqlQuery & | query = qx::QxSqlQuery() , |
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL , |
||
bool | bUseExecBatch = false |
||
) | [inline, virtual] |
Update all items in the model into database.
query | Define a user SQL query added to default SQL query builded by QxOrm library |
relation | List of relationships keys to be inserted 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 (optional parameter) |
bUseExecBatch | If true then use the QSqlQuery::execBatch() method to improve performance updating a list of instances in database |
Reimplemented from qx::QxModel< T, B >.
Definition at line 191 of file QxModelService.h.
virtual QSqlError qx::QxModelService< T, S, B >::qxUpdateRow | ( | int | row, |
const qx::QxSqlQuery & | query = qx::QxSqlQuery() , |
||
const QStringList & | relation = QStringList() , |
||
QSqlDatabase * | pDatabase = NULL |
||
) | [inline, virtual] |
Update an item of the model at line row into database.
row | Update an item in the model at line row |
query | Define a user SQL query added to default SQL query builded by QxOrm library |
relation | List of relationships keys to be inserted 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 (optional parameter) |
Reimplemented from qx::QxModel< T, B >.
Definition at line 206 of file QxModelService.h.
virtual qx::QxInvalidValueX qx::QxModelService< T, S, B >::qxValidate | ( | const QStringList & | groups = QStringList() | ) | [inline, virtual] |
Reimplemented from qx::QxModel< T, B >.
Definition at line 358 of file QxModelService.h.
virtual qx::QxInvalidValueX qx::QxModelService< T, S, B >::qxValidateRow | ( | int | row, |
const QStringList & | groups = QStringList() |
||
) | [inline, virtual] |
Reimplemented from qx::QxModel< T, B >.
Definition at line 367 of file QxModelService.h.