[odb-users] Query only intermediate polymorphic objects

Dieter Govaerts dieter.govaerts at bricsys.com
Thu Nov 9 04:45:45 EST 2017


Hello,

Assume I have following persistent class hierarchy:

Base (abstract)
 |
 +- DerivedA
     |
     +- DerivedB

How can I query (with and without view) only the objects of type "DerivedA"?

For example, I would like to query all ids of objects of type DerivedA but not of type DerivedB (explicitly excluding objects of type DerivedB is not an option as the hierarchy much more complex and under development):

#pragma db view object(DerivedA)
struct DerivedAIdView
{
    unsigned id;
};

odb::result<DerivedAIdView> r(db()->query<DerivedAIdView>());

Regards,
Dieter




More information about the odb-users mailing list