TreeFrogFramework  1.18
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, QVariant value)
 
findByPrimaryKey (QVariant pk)
 
int find (const TCriteria &cri=TCriteria())
 
int findBy (int column, 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, QVariant value)
 
int updateAll (const TCriteria &cri, int column, QVariant value)
 
int updateAll (const TCriteria &cri, const QMap< int, QVariant > &values)
 
int removeAll (const TCriteria &cri=TCriteria())
 
ConstIterator begin () const
 
ConstIterator end () const
 

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

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

Constructor.

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

Destructor.

Member Function Documentation

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

Clears and releases any acquired resource.

template<class T>
ConstIterator TSqlORMapper< T >::end ( ) const
inline
template<class T >
int TSqlORMapper< T >::find ( const TCriteria cri = TCriteria())
inline

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
template<class T >
int TSqlORMapper< T >::findBy ( int  column,
QVariant  value 
)
inline

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
template<class T >
T TSqlORMapper< T >::findByPrimaryKey ( QVariant  pk)
inline

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

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

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

template<class T >
int TSqlORMapper< T >::findCountBy ( int  column,
QVariant  value 
)
inline

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

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.

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

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

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

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
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 &)
template<class T >
template<class C >
TSqlORMapper< T > & TSqlORMapper< T >::join ( int  column,
const TSqlJoin< C > &  join 
)
inline
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 &)
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.

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.

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

Sets the sort order for column to order.

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.

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

Returns a SQL WHERE clause generated from a criteria.

template<class T>
virtual QString TSqlORMapper< T >::orderByClause ( ) const
inlineprotectedvirtual
template<class T >
int TSqlORMapper< T >::removeAll ( const TCriteria cri = TCriteria())
inline

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

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

Reset the internal state of the mapper object.

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

Returns the number of rows of the current query.

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

Returns the number of rows of the current query.

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.

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.

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.

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

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

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

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

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

Sets the sort order for column to order.

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

Sets the sort order for column to order.

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

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.

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

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.

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: