Project

General

Profile

How to create Dbo table classes with the same fields?

Added by Plug Gulp over 3 years ago

How do I create Dbo classes with the same field structure? For instance, I have two tables that contain time field.

Table_1 [
  Wt::WTime
]

Table_2 [
  Wt::WTime
]

Do I need to create two separate Dbo classes in Wt to represent these two tables, like the following?

class TableOne
{
    public:
        Wt::WTime t;

        template<Action a>
        void persist(Action &a)
        {
            Wt::Dbo::id(a, t, "time");
        }
};

class TableTwo
{
    public:
        Wt::WTime t;

        template<Action a>
        void persist(Action &a)
        {
            Wt::Dbo::id(a, t, "time");
        }
};

session.mapClass<TableOne>("Table_1");
session.mapClass<TableTwo>("Table_2");

Or can I just define one cpp class Table; and then map that to Table_1 and Table_2?


Replies (1)

RE: How to create Dbo table classes with the same fields? - Added by Bruce Toll over 3 years ago

I don't believe that it is possible to map a single class to more than one database table, as explained in this thread: How to map 2 tables to same class?

    (1-1/1)