[odb-users] one-to-many relationship with property(ies)

Davide Anastasia Davide.Anastasia at qualitycapital.com
Wed Jun 13 11:48:53 EDT 2012


Hi, I'm back!

I'm trying to build an ODB layer over an already existing database. I
have a one-to-many relationship between table A and table B, with a
middle table containing (primary_key(A), primary_key(B), int). In
practice, I have a relationship with a weight between A and B. I'm not
sure how I can model this. I have tried something like (inside class A):

 

#pragma db unordered value_not_null table("mapping_a_b") \

    key_column("id_B") \

    id_column("id_A") \

    value_column("weight") \

    key_type("VARCHAR(8)") value_type("INT(11)")

    std::map< ::odb::boost::lazy_shared_ptr<B> , int > m_mapping;

 

Unfortunately, I get a lot of errors from the compiler. If I had
"id_type" as well, ODB compiler crashes.

 

Any suggestion?

Thanks,

 

Davide Anastasia
Analyst, Research & Development


Quality Capital Management Ltd.
QCM House * Horizon Business Village
No. 1 Brooklands Road
Weybridge * Surrey KT13 0TJ
United Kingdom

Tel: +44 (0) 1932 334 400
Fax: +44 (0) 1932 334 415
Email: Davide.Anastasia at QualityCapital.com
<mailto:Davide.Anastasia at QualityCapital.com> 

www.qualitycapital.com <http://www.qualitycapital.com/> 

________________________________

This email and any attachments are confidential and intended solely for
the use of the individual(s) to whom it is addressed. 

Any views or opinions presented are solely those of the author and do
not necessarily represent those of Quality Capital Management Ltd. If
you are not the intended recipient, be advised that you have received
this email in error and that any use, dissemination, printing,
forwarding or copying of this email is strictly prohibited. Please
contact the sender if you have received this email in error. You should
also be aware that emails are susceptible to interference and you should
not assume that the contents of this email originated from the sender
above or that they have been accurately reproduced in their original
form. Quality Capital Management Ltd is authorised and regulated by the
Financial Services Authority in the UK and is a member of the National
Futures Association in the US. 

________________________________

 



More information about the odb-users mailing list