I did not specify the meaning of the classes - if it were a has-a  
relationship then  containment (via the existing Wt::dbo capabilities)  
would be appropriate of course, but it can often be the case that  
there are is-a style relationships which have more specialized/extra  
data members compared with the base class. I only bring this up, as it  
seems to me that if Wt::dbo did support this concept then it would  
then cover all the main areas that people desire of ORM.

Paul.
On 2010-06 -17, at 20:29, Thomas Dähling wrote:

> Just out of curiousity: Is there a special reason why are you trying
> to represent a has-a (table A has a relation to table B) relationship
> with an is-a relationship (class B is a specialization of class A)?
>
> 2010/6/17 Paul Harrison <[email protected]>:
>>
>> Hi,
>>
>> I was wondering if there are any plans for being able to map class
>> hierarchies - or indeed if anyone has already done such a thing with
>> Wt::Dbo?
>>
>> I can see that it is possible to have a pattern like
>>
>> class Base {
>>  int bi;
>>
>>  template<class Action>
>>    void persist(Action& a) {
>>        dbo::field(a, bi, "bi"); }
>>
>> }
>> class D1 : public Base {
>>    int da;
>>
>>  template<class Action>
>>    void persist(Action& a) {
>>        base::persist(a);
>>        dbo::field(a, da, "da"); }
>>
>> }
>> class D2 : public Base {
>>    int db;
>>
>>  template<class Action>
>>    void persist(Action& a) {
>>        base::persist(a);
>>        dbo::field(a, db, "db"); }
>>
>> }
>>
>> and then
>> session.mapClass<D1>("D1");
>> session.mapClass<D2>("D2");
>>
>> so that there is one (unrelated) table for each subclass (OK if the
>> base class is abstract). However, it would be nice to be able to map
>> these classes to 3 related tables where there is a 1-to-1 relation
>> between the derived class tables and the base class - I don't think
>> that this is achievable with the current facilities, particularly
>> without introducing extra members to store the relationships - I  
>> think
>> that it would be desirable if the foreign key relations in the  
>> derived
>> classes were automatically managed.
>>
>> Regards,
>>      Paul.
>>
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit.  See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________
>> witty-interest mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/witty-interest
>>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> witty-interest mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/witty-interest

Dr. Paul Harrison
JBCA, Manchester University
http://www.manchester.ac.uk/jodrellbank




------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to