[odb-users] support Multi-field primary key?

Boris Kolpackov boris at codesynthesis.com
Tue Aug 28 08:30:07 EDT 2012


Hi,

Justlive <duhai_lee at qq.com> writes:

> there are multiple field primary key table, how can I do?

You can use a composite value type as an object id:

#pragma db value
struct name
{
  std::string first;
  std::string last;
};

#pragma db object
class person
{
  ...

  #pragma db id
  name name_;
};

For more information, refer to Section 7.2.1, "Composite Object Ids"
in the ODB manual.

Boris



More information about the odb-users mailing list