[odb-users] Inverse and composite Id

Boris Kolpackov boris at codesynthesis.com
Wed Mar 1 11:12:30 EST 2017


Hi Sean,

Sean Clarke <sean.clarke at sec-consulting.co.uk> writes:

> class A {
> 
> #pragma db value
>     struct Id {
>         int a;
>         int b;
> }
> 
> #pragma db id
>     Id m_id;
> 
> #pragma db value_not_null
>     std::shared_ptr<B> m_b;
> 
> };
> 
> 
> class B {
>     using id_t = std::uint32_t;
> 
> #pragma db id
>     id_t m_id;
> 
> #pragma db inverse(m_b)
>     std::vector<std::shared_ptr<A>> m_as;
> };
> 
> /<path>/odb_gen/A-odb.hxx:385:70: error: ‘image_type’ in ‘class
> odb::access::composite_value_traits<B::Id, (odb::database_id)2u>’ does not
> name a type

The error suggests that you have it the other way around (Id is in B, not
A, and A points to B). Assuming this is the case, my guess would be that
the header that contains A doesn't include the one containing B. See
Section 6.3, "Circular Relationships" in the manual for details on the
issue and possible solutions.

Boris



More information about the odb-users mailing list