QxOrm 1.4.9
C++ Object Relational Mapping library
Loading...
Searching...
No Matches

qx::QxPersistableList<T> : concrete class for list persistent classes based on qx::IxPersistableCollection (as an array instead of key/value hash-map) More...

#include <IxPersistableList.h>

Inheritance diagram for qx::QxPersistableList< T >:
qx::IxPersistableCollection qx::IxPersistable

Public Member Functions

 QxPersistableList ()
 
virtual ~QxPersistableList ()
 
virtual long __count () const
 
virtual void __clear ()
 
virtual bool __remove (long idx)
 
virtual qx::IxPersistable_ptr __at (long idx) const
 
virtual long qxCount (const qx::QxSqlQuery &query=qx::QxSqlQuery(), QSqlDatabase *pDatabase=NULL, const QStringList &relation=QStringList())
 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())
 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)
 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)
 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)
 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)
 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)
 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)
 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)
 Delete current instance from database.
 
virtual QSqlError qxDeleteAll (QSqlDatabase *pDatabase=NULL)
 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)
 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)
 Delete current instance from database.
 
virtual QSqlError qxDestroyAll (QSqlDatabase *pDatabase=NULL)
 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)
 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)
 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)
 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)
 Search if current instance already exists into database.
 
virtual qx::QxInvalidValueX qxValidate (const QStringList &groups=QStringList())
 Check if current instance is valid or not.
 
virtual std::shared_ptr< qx::IxPersistableCollectionqxNewPersistableCollection (bool bAsList=false) const
 Create a new collection smart-pointer to fetch a list of items of current class type.
 
virtual qx::IxClassqxClass () const
 Access to introspection engine (or reflection engine) of QxOrm library.
 
virtual QString toJson (const QString &format=QString()) const
 
virtual QJsonValue toJson_ (const QString &format=QString()) const
 
virtual qx_bool fromJson (const QString &json, const QString &format=QString())
 
virtual qx_bool fromJson_ (const QJsonValue &json, const QString &format=QString())
 
- Public Member Functions inherited from qx::IxPersistableCollection
 IxPersistableCollection ()
 
virtual ~IxPersistableCollection ()
 
- Public Member Functions inherited from qx::IxPersistable
 IxPersistable ()
 
virtual ~IxPersistable ()
 

Protected Attributes

QList< std::shared_ptr< T > > m_list
 List of persistable instances.
 

Private Types

enum  { qx_is_valid = qx::trait::is_qx_registered<T>::value }
 

Additional Inherited Members

- Static Public Member Functions inherited from qx::IxPersistable
static std::shared_ptr< qx::IxPersistableCollectionqxFetchAll (const QString &className, const QStringList &columns=QStringList(), const QStringList &relation=QStringList(), QSqlDatabase *pDatabase=NULL, bool bAsList=false)
 
static std::shared_ptr< qx::IxPersistableCollectionqxFetchByQuery (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::IxPersistableCollectionqxExecuteQuery (const QString &className, qx::QxSqlQuery &query, QSqlDatabase *pDatabase=NULL, bool bAsList=false)
 

Detailed Description

template<typename T>
class qx::QxPersistableList< T >

qx::QxPersistableList<T> : concrete class for list persistent classes based on qx::IxPersistableCollection (as an array instead of key/value hash-map)

Definition at line 63 of file IxPersistableList.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T >
anonymous enum
private
Enumerator
qx_is_valid 

Definition at line 66 of file IxPersistableList.h.

Constructor & Destructor Documentation

◆ QxPersistableList()

template<typename T >
qx::QxPersistableList< T >::QxPersistableList ( )
inline

Definition at line 74 of file IxPersistableList.h.

◆ ~QxPersistableList()

template<typename T >
virtual qx::QxPersistableList< T >::~QxPersistableList ( )
inlinevirtual

Definition at line 75 of file IxPersistableList.h.

Member Function Documentation

◆ __at()

template<typename T >
virtual qx::IxPersistable_ptr qx::QxPersistableList< T >::__at ( long idx) const
inlinevirtual

Implements qx::IxPersistableCollection.

Definition at line 80 of file IxPersistableList.h.

◆ __clear()

template<typename T >
virtual void qx::QxPersistableList< T >::__clear ( )
inlinevirtual

Implements qx::IxPersistableCollection.

Definition at line 78 of file IxPersistableList.h.

◆ __count()

template<typename T >
virtual long qx::QxPersistableList< T >::__count ( ) const
inlinevirtual

Implements qx::IxPersistableCollection.

Definition at line 77 of file IxPersistableList.h.

◆ __remove()

template<typename T >
virtual bool qx::QxPersistableList< T >::__remove ( long idx)
inlinevirtual

Implements qx::IxPersistableCollection.

Definition at line 79 of file IxPersistableList.h.

◆ fromJson()

template<typename T >
virtual qx_bool qx::QxPersistableList< T >::fromJson ( const QString & json,
const QString & format = QString() )
inlinevirtual

Implements qx::IxPersistable.

Definition at line 187 of file IxPersistableList.h.

◆ fromJson_()

template<typename T >
virtual qx_bool qx::QxPersistableList< T >::fromJson_ ( const QJsonValue & json,
const QString & format = QString() )
inlinevirtual

Implements qx::IxPersistable.

Definition at line 190 of file IxPersistableList.h.

◆ qxClass()

template<typename T >
virtual qx::IxClass * qx::QxPersistableList< T >::qxClass ( ) const
inlinevirtual

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...)

Implements qx::IxPersistable.

Definition at line 176 of file IxPersistableList.h.

◆ qxCount() [1/2]

template<typename T >
virtual long qx::QxPersistableList< T >::qxCount ( const qx::QxSqlQuery & query = qx::QxSqlQuery(),
QSqlDatabase * pDatabase = NULL,
const QStringList & relation = QStringList() )
inlinevirtual

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
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection 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
relationList 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...

Implements qx::IxPersistable.

Definition at line 82 of file IxPersistableList.h.

◆ qxCount() [2/2]

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxCount ( long & lCount,
const qx::QxSqlQuery & query = qx::QxSqlQuery(),
QSqlDatabase * pDatabase = NULL,
const QStringList & relation = QStringList() )
inlinevirtual

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
lCountOutput parameter with the number of lines in the table associated to the SQL query
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection 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
relationList 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...

Implements qx::IxPersistable.

Definition at line 88 of file IxPersistableList.h.

◆ qxDeleteAll()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDeleteAll ( QSqlDatabase * pDatabase = NULL)
inlinevirtual

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

Parameters
pDatabaseConnection 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'

Implements qx::IxPersistable.

Definition at line 146 of file IxPersistableList.h.

◆ qxDeleteById()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDeleteById ( const QVariant & id = QVariant(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

Delete current instance from database.

Parameters
idUnique id to delete from database (if empty, check id of current instance)
pDatabaseConnection 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
bUseExecBatchIf 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 = ?

Implements qx::IxPersistable.

Definition at line 143 of file IxPersistableList.h.

◆ qxDeleteByQuery()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDeleteByQuery ( const qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection 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...

Implements qx::IxPersistable.

Definition at line 149 of file IxPersistableList.h.

◆ qxDestroyAll()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDestroyAll ( QSqlDatabase * pDatabase = NULL)
inlinevirtual

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

Parameters
pDatabaseConnection 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

Implements qx::IxPersistable.

Definition at line 155 of file IxPersistableList.h.

◆ qxDestroyById()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDestroyById ( const QVariant & id = QVariant(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

Delete current instance from database.

Parameters
idUnique id to delete from database (if empty, check id of current instance)
pDatabaseConnection 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
bUseExecBatchIf 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 = ?

Implements qx::IxPersistable.

Definition at line 152 of file IxPersistableList.h.

◆ qxDestroyByQuery()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxDestroyByQuery ( const qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection 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...

Implements qx::IxPersistable.

Definition at line 158 of file IxPersistableList.h.

◆ qxExecuteQuery() [1/2]

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxExecuteQuery ( qx::QxSqlQuery & query,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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
queryDefine a user SQL query added to default SQL query builded by QxOrm library
pDatabaseConnection 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

Implements qx::IxPersistable.

Definition at line 161 of file IxPersistableList.h.

◆ qxExecuteQuery() [2/2]

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxExecuteQuery ( qx::QxSqlQuery & query,
qx::IxPersistableCollection * list = NULL,
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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
queryDefine a user SQL query added to default SQL query builded by QxOrm library
listContainer to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
pDatabaseConnection 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

Implements qx::IxPersistable.

Definition at line 164 of file IxPersistableList.h.

◆ qxExist()

template<typename T >
virtual qx_bool qx::QxPersistableList< T >::qxExist ( const QVariant & id = QVariant(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

Search if current instance already exists into database.

Parameters
idUnique id to check into database (if empty, check id of current instance)
pDatabaseConnection 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 = ?

Implements qx::IxPersistable.

Definition at line 167 of file IxPersistableList.h.

◆ qxFetchAll()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxFetchAll ( qx::IxPersistableCollection * list = NULL,
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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
listContainer to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
columnsList of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
relationList 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
pDatabaseConnection 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

Implements qx::IxPersistable.

Definition at line 102 of file IxPersistableList.h.

◆ qxFetchById()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxFetchById ( const QVariant & id = QVariant(),
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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
idUnique id to fetch properties from database (if empty, check id of current instance)
columnsList of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
relationList 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
pDatabaseConnection 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 = ?

Implements qx::IxPersistable.

Definition at line 94 of file IxPersistableList.h.

◆ qxFetchByQuery()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxFetchByQuery ( const qx::QxSqlQuery & query,
qx::IxPersistableCollection * list = NULL,
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL )
inlinevirtual

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
queryDefine a user SQL query added to default SQL query builded by QxOrm library
listContainer to fetch all items (retrieve all elements and properties associated); list is cleared before executing SQL query
columnsList of database table columns (mapped to properties of C++ class) to fetch (if empty, all columns are fetched)
relationList 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
pDatabaseConnection 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...

Implements qx::IxPersistable.

Definition at line 110 of file IxPersistableList.h.

◆ qxInsert()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxInsert ( const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

Insert current instance into database.

Parameters
relationList of relationships keys to insert in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection 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
bUseExecBatchIf 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.)

Implements qx::IxPersistable.

Definition at line 118 of file IxPersistableList.h.

◆ qxNewPersistableCollection()

template<typename T >
virtual std::shared_ptr< qx::IxPersistableCollection > qx::QxPersistableList< T >::qxNewPersistableCollection ( bool bAsList = false) const
inlinevirtual

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

Parameters
bAsListIf 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

Implements qx::IxPersistable.

Definition at line 173 of file IxPersistableList.h.

◆ qxSave()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxSave ( const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL,
qx::dao::save_mode::e_save_mode eSaveRecursiveMode = qx::dao::save_mode::e_none )
inlinevirtual

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

Parameters
relationList of relationships keys to insert or update in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection 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
eSaveRecursiveModeParameter 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.

Implements qx::IxPersistable.

Definition at line 134 of file IxPersistableList.h.

◆ qxUpdate()

template<typename T >
virtual QSqlError qx::QxPersistableList< T >::qxUpdate ( const qx::QxSqlQuery & query = qx::QxSqlQuery(),
const QStringList & columns = QStringList(),
const QStringList & relation = QStringList(),
QSqlDatabase * pDatabase = NULL,
bool bUseExecBatch = false )
inlinevirtual

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

Parameters
queryDefine a user SQL query added to default SQL query builded by QxOrm library
columnsList of database table columns (mapped to properties of C++ class) to update (if empty, all columns are updated)
relationList of relationships keys to update in others tables of database : use "|" separator to put many relationships keys into this parameter
pDatabaseConnection 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
bUseExecBatchIf 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...

Implements qx::IxPersistable.

Definition at line 126 of file IxPersistableList.h.

◆ qxValidate()

template<typename T >
virtual qx::QxInvalidValueX qx::QxPersistableList< T >::qxValidate ( const QStringList & groups = QStringList())
inlinevirtual

Check if current instance is valid or not.

Parameters
groupsList 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

Implements qx::IxPersistable.

Definition at line 170 of file IxPersistableList.h.

◆ toJson()

template<typename T >
virtual QString qx::QxPersistableList< T >::toJson ( const QString & format = QString()) const
inlinevirtual

Implements qx::IxPersistable.

Definition at line 181 of file IxPersistableList.h.

◆ toJson_()

template<typename T >
virtual QJsonValue qx::QxPersistableList< T >::toJson_ ( const QString & format = QString()) const
inlinevirtual

Implements qx::IxPersistable.

Definition at line 184 of file IxPersistableList.h.

Member Data Documentation

◆ m_list

template<typename T >
QList<std::shared_ptr<T> > qx::QxPersistableList< T >::m_list
protected

List of persistable instances.

Definition at line 70 of file IxPersistableList.h.


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