[odb-users] Inverse and composite Id

Sean Clarke sean.clarke at sec-consulting.co.uk
Tue Feb 28 15:49:11 EST 2017

    I am having some problems trying to model a many-to-one relationship
where one entity has a composite primary key (I think that is the issue).

Trying to define what I am doing (this is a cut down definition - ignore
any compilation errors, this is just to summarise):

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;

The error I get when I compile is along the lines of:

/<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
         composite_value_traits< ::B::Id, id_pgsql >::image_type


Any hints on what I am doing wrong?

Sean Clarke

More information about the odb-users mailing list