TreeFrogFramework  1.18
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TSqlObject Class Reference

#include <tsqlobject.h>

Inheritance diagram for TSqlObject:
Inheritance graph
[legend]
Collaboration diagram for TSqlObject:
Collaboration graph
[legend]

Public Member Functions

 TSqlObject ()
 
 TSqlObject (const TSqlObject &other)
 
TSqlObjectoperator= (const TSqlObject &other)
 
virtual ~TSqlObject ()
 
virtual QString tableName () const
 
virtual int primaryKeyIndex () const
 
virtual int autoValueIndex () const
 
virtual int databaseId () const
 
void setRecord (const QSqlRecord &record, const QSqlError &error)
 
bool create () override
 
bool update () override
 
bool save () override
 
bool remove () override
 
bool reload ()
 
bool isNull () const override
 
bool isNew () const
 
bool isModified () const
 
void clear ()
 
QSqlError error () const
 
- Public Member Functions inherited from TModelObject
 TModelObject ()
 
virtual ~TModelObject ()
 
virtual void setProperties (const QVariantMap &value)
 
virtual QVariantMap toVariantMap () const
 
virtual QStringList propertyNames () const
 

Protected Member Functions

void syncToSqlRecord ()
 
void syncToObject ()
 

Protected Attributes

QSqlError sqlError
 

Detailed Description

The TSqlObject class is the base class of ORM objects.

See also
TSqlORMapper

Constructor & Destructor Documentation

TSqlObject::TSqlObject ( )

Constructor.

TSqlObject::TSqlObject ( const TSqlObject other)

Copy constructor.

virtual TSqlObject::~TSqlObject ( )
inlinevirtual

Member Function Documentation

int TSqlObject::autoValueIndex ( ) const
inlinevirtual

Returns the position of the auto-generated value field on the table.

This is a virtual function.

void TSqlObject::clear ( )
inlinevirtual

Clears the contents of the object.

Reimplemented from TModelObject.

bool TSqlObject::create ( )
overridevirtual

Inserts new record into the database, based on the current properties of the object.

Implements TModelObject.

int TSqlObject::databaseId ( ) const
inlinevirtual

Returns the database ID.

QSqlError TSqlObject::error ( ) const
inline

Returns a QSqlError object which contains information about the last error that occurred on the database.

bool TSqlObject::isModified ( ) const

Returns true if the values of the properties differ with the record on the database; otherwise returns false.

bool TSqlObject::isNew ( ) const
inline

Returns true if it is a new object, otherwise returns false.

Equivalent to isNull().

bool TSqlObject::isNull ( ) const
inlineoverridevirtual

Returns true if there is no database record associated with the object; otherwise returns false.

Implements TModelObject.

TSqlObject & TSqlObject::operator= ( const TSqlObject other)

Assignment operator.

int TSqlObject::primaryKeyIndex ( ) const
inlinevirtual

Returns the position of the primary key field on the table.

This is a virtual function.

bool TSqlObject::reload ( )

Reloads the values of the record onto the properties.

bool TSqlObject::remove ( )
overridevirtual

Deletes the record with this primary key from the database.

Implements TModelObject.

bool TSqlObject::save ( )
overridevirtual

Depending on whether condition matches, inserts new record or updates the corresponding record with the properties of the object.

If possible, invokes UPSERT in relational database.

Implements TModelObject.

void TSqlObject::setRecord ( const QSqlRecord &  record,
const QSqlError &  error 
)

Sets the record.

This function is for internal use only.

void TSqlObject::syncToObject ( )
protected

Synchronizes the internal record data to the properties of the object.

This function is for internal use only.

void TSqlObject::syncToSqlRecord ( )
protected

Synchronizes the properties to the internal record data.

This function is for internal use only.

QString TSqlObject::tableName ( ) const
virtual

Returns the table name, which is generated from the class name.

bool TSqlObject::update ( )
overridevirtual

Updates the corresponding record with the properties of the object.

Implements TModelObject.

Member Data Documentation

QSqlError TSqlObject::sqlError
protected

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