1

What is the right way to define a table (“secondtable”) with multiple primary key, one of them (“|first_table_key”) is a “many to one” relation to another table (“firsttable”)?

This doesen't work because of multiple definitions of “first_table_key”!

namespace qx 
{
template <> void register_class(QxClass<secondtable> & t)
{
   t.id(&secondtable::m_id, “second_table _key|first_table_key”);
   t.data(&secondtable::m_text, "second_table_text");
   t.relationManyToOne(&secondtable::m_firsttable, “first_table_key”);
}
}
maxw
  • 123
  • 1
  • 8

1 Answers1

0

Try this :

namespace qx 
{
template <> void register_class(QxClass<secondtable> & t)
{
   t.id(&secondtable::m_id, “second_table _key|first_table_key”);
   t.data(&secondtable::m_text, "second_table_text");
   qx::IxSqlRelation * pRelation = t.relationManyToOne(&secondtable::m_firsttable, “first_table”);
   pRelation->getDataMember()->setName("first_table_key");
}
}

As you can see, you can define your relation with another key (first_table), which is not the same key as your primary key (first_table_key). And then, just put the correct name of your relation using pRelation->getDataMember()->setName() method.

QxOrm
  • 56
  • 2