Wt::Dbo::Dbo Class Reference
[Database Objects library (Dbo)]

A base class for database objects. More...

#include <Wt/Dbo/Dbo>

List of all members.

Public Member Functions

 Dbo ()
 Constructor.
long long id () const
 Returns the database id.
Sessionsession () const
 Returns the session.

Detailed Description

A base class for database objects.

The only requirement for a class to be be persisted is to have a persist() method. In some cases however, it may be convenient to be able to access database information of an object, such as its database id and its session, from the object itself.

By deriving your database class directly or indirectly from this class, you can have access to its id() and session(). This will increase the size of your object with one pointer.

The following example shows a skeleton for a database object which has access to its own id and session information:

 class Cat : public dbo::Dbo {
 public:
   template <class Action>
   void persist(Action& a) { }
 };

Compared to the skeletong for a minimum valid database class:

 class Cat {
 public:
   template <class Action>
   void persist(Action& a) { }
 };

Member Function Documentation

long long Wt::Dbo::Dbo::id (  )  const

Returns the database id.

Returns the database id of this object, or -1 if the object is associated with a session or not yet stored in the database.

Session * Wt::Dbo::Dbo::session (  )  const

Returns the session.

Returns the session to which this object belongs, or 0 if the object is not associated with a session.


Generated on Thu May 13 05:16:19 2010 for Wt by doxygen 1.6.3