[odb-users] Bi-directional mapping to Abstract class

Bright Dadson losintikfos at yahoo.co.uk
Sun Aug 14 18:35:38 EDT 2011


This thread has been posted already, didn't know how to modify the previous as I had mistakes in it, so I thought I resend it again. I have a file called `Account.h` as shown below:

    #ifndef ACCOUNT_H_
    #define ACCOUNT_H_

   //forward declaration of address
   class Address address;
    
    #pragma db object abstract
    class Account
    {
      //fields and methods
      //Inverse bi-directional mapping to Address 
    };
    #endif /* ACCOUNT_H_ */

I also have a second file called `Address.h` as shown below:

    #ifndef ADDRESS_H_
    #define ADDRESS_H_
    #include "Account.h"
    
    typedef Account account_type;
   
 class Address
    {
     //Fields and methods
     ...
     //Mapping to account_type //..Error here
    };
    #endif /* ADDRESS_H_ */

My
 problem is, when I try to map to Account, I get the error `Account is 
Abstract`. I want to be able to map to the abstract instead of mappping 
to each child inherited class - I think doing it this way will remove the verbosity
 of the mapping code across inherited classes.

Is there a simple 
way of doing this, can I map to the abstract base class, so all children
 classes will inherit this? 

Also Is my forward declaration of Address in
 Account correct? well considering they are different files.

Thanks.



More information about the odb-users mailing list