TreeFrogFramework 2.10
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | List of all members
TSqlORMapper< T > Class Template Reference

#include <tsqlormapper.h>

Inheritance diagram for TSqlORMapper< T >:
Inheritance graph
[legend]
Collaboration diagram for TSqlORMapper< T >:
Collaboration graph
[legend]

Classes

class  ConstIterator
 

Public Member Functions

 TSqlORMapper ()
 
virtual ~TSqlORMapper ()
 
TSqlORMapper< T > & limit (int limit)
 
TSqlORMapper< T > & offset (int offset)
 
TSqlORMapper< T > & orderBy (int column, Tf::SortOrder order=Tf::AscendingOrder)
 
TSqlORMapper< T > & orderBy (const QString &column, Tf::SortOrder order=Tf::AscendingOrder)
 
template<class C >
TSqlORMapper< T > & join (int column, const TSqlJoin< C > &join)
 
void setLimit (int limit)
 
void setOffset (int offset)
 
void setSortOrder (int column, Tf::SortOrder order=Tf::AscendingOrder)
 
void setSortOrder (const QString &column, Tf::SortOrder order=Tf::AscendingOrder)
 
template<class C >
void setJoin (int column, const TSqlJoin< C > &join)
 
void reset ()
 
findFirst (const TCriteria &cri=TCriteria())
 
findFirstBy (int column, const QVariant &value)
 
findByPrimaryKey (const QVariant &pk)
 
int find (const TCriteria &cri=TCriteria())
 
int findBy (int column, const QVariant &value)
 
int findIn (int column, const QVariantList &values)
 
int rowCount () const
 
first () const
 
last () const
 
value (int i) const
 
int findCount (const TCriteria &cri=TCriteria())
 
int findCountBy (int column, const QVariant &value)
 
int updateAll (const TCriteria &cri, int column, const QVariant &value)
 
int updateAll (const TCriteria &cri, const QMap< int, QVariant > &values)
 
int removeAll (const TCriteria &cri=TCriteria())
 
ConstIterator begin () const
 
ConstIterator end () const
 
- Public Member Functions inherited from TAbstractSqlORMapper
 TAbstractSqlORMapper (const QSqlDatabase &db)
 
virtual ~TAbstractSqlORMapper ()
 

Protected Member Functions

void setFilter (const QString &filter)
 
QString orderBy () const
 
virtual QString orderByClause () const
 
virtual void clear ()
 
virtual QString selectStatement () const
 
virtual int rowCount (const QModelIndex &parent) const
 

Detailed Description

template<class T>
class TSqlORMapper< T >

The TSqlORMapper class is a template class that provides concise functionality to object-relational mapping.

It can be used to retrieve TSqlObject objects with a TCriteria from a table.

See also
TSqlObject, TCriteria

Constructor & Destructor Documentation

◆ TSqlORMapper()

template<class T >
TSqlORMapper< T >::TSqlORMapper ( )
inline

Constructor.

◆ ~TSqlORMapper()

template<class T >
TSqlORMapper< T >::~TSqlORMapper ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ begin()

template<class T >
ConstIterator TSqlORMapper< T >::begin ( ) const
inline

◆ clear()

template<class T >
void TSqlORMapper< T >::clear ( )
inlineprotectedvirtual

Clears and releases any acquired resource.

◆ end()

template<class T >
ConstIterator TSqlORMapper< T >::end ( ) const
inline

◆ find()

template<class T >
int TSqlORMapper< T >::find ( const TCriteria cri = TCriteria())
inlinevirtual

Retrieves with the criteria cri from the table and returns the number of the ORM objects.

TSqlORMapperIterator is used to get the retrieved ORM objects.

See also
TSqlORMapperIterator

Implements TAbstractSqlORMapper.

◆ findBy()

template<class T >
int TSqlORMapper< T >::findBy ( int  column,
const QVariant &  value 
)
inlinevirtual

Retrieves with the criteria for the column as the value in the table and returns the number of the ORM objects.

TSqlORMapperIterator is used to get the retrieved ORM objects.

See also
TSqlORMapperIterator

Implements TAbstractSqlORMapper.

◆ findByPrimaryKey()

template<class T >
T TSqlORMapper< T >::findByPrimaryKey ( const QVariant &  pk)
inline

Returns the ORM object retrieved with the primary key pk from the table.

◆ findCount()

template<class T >
int TSqlORMapper< T >::findCount ( const TCriteria cri = TCriteria())
inlinevirtual

Returns the number of records retrieved with the criteria cri from the table.

Implements TAbstractSqlORMapper.

◆ findCountBy()

template<class T >
int TSqlORMapper< T >::findCountBy ( int  column,
const QVariant &  value 
)
inlinevirtual

Returns the number of records retrieved with the criteria for the column as the value from the table.

Implements TAbstractSqlORMapper.

◆ findFirst()

template<class T >
T TSqlORMapper< T >::findFirst ( const TCriteria cri = TCriteria())
inline

Returns the first ORM object retrieved with the criteria cri from the table.

◆ findFirstBy()

template<class T >
T TSqlORMapper< T >::findFirstBy ( int  column,
const QVariant &  value 
)
inline

Returns the first ORM object retrieved with the criteria for the column as the value in the table.

◆ findIn()

template<class T >
int TSqlORMapper< T >::findIn ( int  column,
const QVariantList &  values 
)
inlinevirtual

Retrieves with the criteria that the column is within the list of values values returns the number of the ORM objects.

TSqlORMapperIterator is used to get the retrieved ORM objects.

See also
TSqlORMapperIterator

Implements TAbstractSqlORMapper.

◆ first()

template<class T >
T TSqlORMapper< T >::first ( ) const
inline

Returns the first ORM object in the results retrieved by find() function.

See also
find(const TCriteria &)

◆ join()

template<class T >
template<class C >
TSqlORMapper< T > & TSqlORMapper< T >::join ( int  column,
const TSqlJoin< C > &  join 
)
inline

◆ last()

template<class T >
T TSqlORMapper< T >::last ( ) const
inline

Returns the last ORM object in the results retrieved by find() function.

See also
find(const TCriteria &)

◆ limit()

template<class T >
TSqlORMapper< T > & TSqlORMapper< T >::limit ( int  limit)
inline

Sets the limit to limit, which is the limited number of rows for execution of SELECT statement.

◆ offset()

template<class T >
TSqlORMapper< T > & TSqlORMapper< T >::offset ( int  offset)
inline

Sets the offset to offset, which is the number of rows to skip for execution of SELECT statement.

◆ orderBy() [1/3]

template<class T >
QString TSqlORMapper< T >::orderBy ( ) const
inlineprotected

Returns a SQL WHERE clause generated from a criteria.

◆ orderBy() [2/3]

template<class T >
TSqlORMapper< T > & TSqlORMapper< T >::orderBy ( const QString &  column,
Tf::SortOrder  order = Tf::AscendingOrder 
)
inline

Sets the sort order for column to order.

◆ orderBy() [3/3]

template<class T >
TSqlORMapper< T > & TSqlORMapper< T >::orderBy ( int  column,
Tf::SortOrder  order = Tf::AscendingOrder 
)
inline

Sets the sort order for column to order.

◆ orderByClause()

template<class T >
virtual QString TSqlORMapper< T >::orderByClause ( ) const
inlineprotectedvirtual

◆ removeAll()

template<class T >
int TSqlORMapper< T >::removeAll ( const TCriteria cri = TCriteria())
inlinevirtual

Removes all rows based on the criteria cri from the table and returns the number of the rows affected by the query executed.

Implements TAbstractSqlORMapper.

◆ reset()

template<class T >
void TSqlORMapper< T >::reset ( )
inlinevirtual

Reset the internal state of the mapper object.

Implements TAbstractSqlORMapper.

◆ rowCount() [1/2]

template<class T >
int TSqlORMapper< T >::rowCount ( ) const
inline

Returns the number of rows of the current query.

◆ rowCount() [2/2]

template<class T >
int TSqlORMapper< T >::rowCount ( const QModelIndex &  parent) const
inlineprotectedvirtual

Returns the number of rows of the current query.

◆ selectStatement()

template<class T >
QString TSqlORMapper< T >::selectStatement ( ) const
inlineprotectedvirtual

Returns a SELECT statement generated from the specified parameters.

This function is for internal use only.

◆ setFilter()

template<class T >
void TSqlORMapper< T >::setFilter ( const QString &  filter)
inlineprotected

Sets the current filter to filter.

The filter is a SQL WHERE clause without the keyword WHERE (for example, name='Hanako'). The filter will be applied the next time a query is executed.

◆ setJoin()

template<class T >
template<class C >
void TSqlORMapper< T >::setJoin ( int  column,
const TSqlJoin< C > &  join 
)
inline

Sets a JOIN clause for column to join.

◆ setLimit()

template<class T >
void TSqlORMapper< T >::setLimit ( int  limit)
inlinevirtual

Sets the limit to limit, which is the limited number of rows for execution of SELECT statement.

Implements TAbstractSqlORMapper.

◆ setOffset()

template<class T >
void TSqlORMapper< T >::setOffset ( int  offset)
inlinevirtual

Sets the offset to offset, which is the number of rows to skip for execution of SELECT statement.

Implements TAbstractSqlORMapper.

◆ setSortOrder() [1/2]

template<class T >
void TSqlORMapper< T >::setSortOrder ( const QString &  column,
Tf::SortOrder  order = Tf::AscendingOrder 
)
inlinevirtual

Sets the sort order for column to order.

Implements TAbstractSqlORMapper.

◆ setSortOrder() [2/2]

template<class T >
void TSqlORMapper< T >::setSortOrder ( int  column,
Tf::SortOrder  order = Tf::AscendingOrder 
)
inlinevirtual

Sets the sort order for column to order.

Implements TAbstractSqlORMapper.

◆ updateAll() [1/2]

template<class T >
int TSqlORMapper< T >::updateAll ( const TCriteria cri,
const QMap< int, QVariant > &  values 
)
virtual

Updates the values of the columns specified in the first elements in the each pairs of values in all rows that satisfy the criteria cri and returns the number of the rows affected by the query executed.

Implements TAbstractSqlORMapper.

◆ updateAll() [2/2]

template<class T >
int TSqlORMapper< T >::updateAll ( const TCriteria cri,
int  column,
const QVariant &  value 
)
inlinevirtual

Updates the value of the specified column in all rows that satisfy the criteria cri and returns the number of the rows affected by the query executed.

Implements TAbstractSqlORMapper.

◆ value()

template<class T >
T TSqlORMapper< T >::value ( int  i) const
inline

Returns the ORM object in the results retrieved by find() function.

If i is the index of a valid row on the results, the ORM object will be populated with values from that row.


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