KDbTransaction

Search for usage in LXR

#include <KDbTransaction.h>

Public Types

enum class  CommitOption { None = 0 , IgnoreInactive = 1 }
 
typedef QFlags< CommitOptionCommitOptions
 

Public Member Functions

 KDbTransaction ()
 
 KDbTransaction (const KDbTransaction &trans)
 
KDbConnectionconnection ()
 
const KDbConnectionconnection () const
 
bool isActive () const
 
bool isNull () const
 
bool operator!= (const KDbTransaction &other) const
 
KDbTransactionoperator= (const KDbTransaction &trans)
 
bool operator== (const KDbTransaction &other) const
 

Protected Attributes

KDbTransactionDatam_data
 

Detailed Description

This class encapsulates a single database transaction.

The KDbTransaction handle abstracts a database transaction for given database connection. Transaction objects are value-based, implicitly shared.

Lifetime of the transaction object is closely related to a KDbConnection object. Deleting the either instance does not commit or rollback the actual transaction. Use KDbTransactionGuard for automatic commits or rolls back.

See also
KDbConnection::beginTransaction()

Definition at line 43 of file KDbTransaction.h.

Member Typedef Documentation

◆ CommitOptions

Member Enumeration Documentation

◆ CommitOption

enum class KDbTransaction::CommitOption
strong

Options for commiting and rolling back transactions.

See also
KDbConnection::beginTransaction() KDbConnection::rollbackTransaction()
KDbTransactionGuard::commit() KDbTransactionGuard::rollback()
Enumerator
IgnoreInactive 

Do not return error for inactive or null transactions when requesting commit or rollback.

Definition at line 63 of file KDbTransaction.h.

Constructor & Destructor Documentation

◆ KDbTransaction() [1/2]

KDbTransaction::KDbTransaction ( )

Constructs a null transaction.

Note
It can be initialized only by KDbConnection.

Definition at line 111 of file KDbTransaction.cpp.

◆ KDbTransaction() [2/2]

KDbTransaction::KDbTransaction ( const KDbTransaction & trans)

Copy constructor.

Definition at line 116 of file KDbTransaction.cpp.

◆ ~KDbTransaction()

KDbTransaction::~KDbTransaction ( )

Definition at line 127 of file KDbTransaction.cpp.

Member Function Documentation

◆ connection() [1/2]

KDbConnection * KDbTransaction::connection ( )

Returns database connection for which the transaction belongs.

nullptr is returned for null transactions.

Definition at line 173 of file KDbTransaction.cpp.

◆ connection() [2/2]

const KDbConnection * KDbTransaction::connection ( ) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
3.1

Definition at line 178 of file KDbTransaction.cpp.

◆ isActive()

bool KDbTransaction::isActive ( ) const

Returns true if transaction is active (i.e.

started)

Returns
false also if transaction is uninitialised (null) or not started.
See also
KDbConnection::beginTransaction()
Since
3.1

Definition at line 183 of file KDbTransaction.cpp.

◆ isNull()

bool KDbTransaction::isNull ( ) const

Returns true if this transaction is null.

Null implies !isActive().

Definition at line 188 of file KDbTransaction.cpp.

◆ operator!=()

bool KDbTransaction::operator!= ( const KDbTransaction & other) const
inline
Returns
true if this transaction is not equal to other; otherwise returns false.
Since
3.1

Definition at line 83 of file KDbTransaction.h.

◆ operator=()

KDbTransaction & KDbTransaction::operator= ( const KDbTransaction & trans)

Definition at line 145 of file KDbTransaction.cpp.

◆ operator==()

bool KDbTransaction::operator== ( const KDbTransaction & other) const

Returns true if this transaction is equal to other; otherwise returns false.

Two transactions are equal if they encapsulate the same physical transaction, i.e. copy constructor or assignment operator was used. Two null transaction objects are equal.

Definition at line 168 of file KDbTransaction.cpp.

Member Data Documentation

◆ m_data

KDbTransactionData* KDbTransaction::m_data
protected

Definition at line 118 of file KDbTransaction.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:19:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.