[odb-users] Defining one-to-many bidirectional relationship

david bowe dpbowe at hotmail.com
Fri Feb 10 03:45:59 EST 2017


Thanks for the reply Micheal,


Although, I'm not quite sure I understand. Do you mean that I should only use a reference pointer on one side of the database map? I want to be able to query up and down through the relationship as necessary.


David

________________________________
From: Michael <mwpowellhtx at gmail.com>
Sent: 09 February 2017 17:29
To: david bowe
Subject: Re: [odb-users] Defining one-to-many bidirectional relationship



On February 9, 2017 5:53:45 AM EST, david bowe <dpbowe at hotmail.com> wrote:
>Hi there,
>
>
>I have been trying to define a one to many relationship with the
>attached code. However, when defining the relationship pointers I get
>the below error asking me to define a database type. I can do this and
>the code will compile but it creates a relationship through a
>supplier_order table which is not what I need. I need each order to
>reference one suppler

That's not typically how best to normalize this kind of object to database mapping. Doesn't matter if we're talking about odb/C++ or NHibernate/C#. What you described is more of a domain layer and/or business logic concern IMPO.

In this case the * on the order to supply side is 1, but the mapping can be the same.

HTH

>database.hxx:111:46: error: unable to map C++ type
>'::__gnu_cxx::new_allocator< ::boost::weak_ptr< ::order > >::this_type'
>used in data member 'orders_' to a PostgreSQL database type
>
>database.hxx:111:46: info: use '#pragma db value_type' to specify the
>database type
>
>
>Could anybody help me with what I am doing wrong?
>
>
>Thanks,
>
>
>David

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.


More information about the odb-users mailing list