Hello!

2,3) No. Abstract class can not be mapped to database. I think,
reading from database is implemented as follows: Wt::Dbo creates
instance of mapped C++ class using default constructor and then
applies .persist() method to set values from database to all fields of
this instance. Instance of abstract class can not be created, so we
get a compile error.

1) Possible (see example)
For each class (base and descendant), you should create a separate
table in database.
Add method .persist() to descendant class, which calls .persist()
method of its base class:

class A {
public:
    int x;

    template<class Action>
    void persist(Action& a) {
        dbo::field(a, x, "x");
    }
};

class B : public A {
public:
    int y;

    template<class Action>
    void persist(Action& a) {
        A::persist(a);
        dbo::field(a, y, "y");
    }
};

session.mapClass<A>("class_a");
session.mapClass<B>("class_b");

Inheritance seems to work even if base class was inherited from
dbo::Dbo<A> template, but this is not documented.
http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1Dbo_1_1Dbo.html


2012/4/23 Tero Mäntyvaara <[email protected]>:
> Hi,
>
> I have three questions about inheritance and abstraction: is it possible...
> 1) ...to Wt::Dbo persistence class be inherited from another?
> 2) ...to make persistence class abstract?
> 3) ...inherit persistence class from abstract persistence class?
>
>
> Tero
>
> ------------------------------------------------------------------------------
> For Developers, A Lot Can Happen In A Second.
> Boundary is the first to Know...and Tell You.
> Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
> http://p.sf.net/sfu/Boundary-d2dvs2
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest

------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to