[odb-users] Composite primary key support
fforcus at rambler.ru
fforcus at rambler.ru
Wed Sep 7 15:20:31 EDT 2011
I have tried to generate database scheme for class Composite which have
composite primary key:
#pragma db value
class CompositeKey {
public:
CompositeKey () {
}
int first;
int second;
};
#pragma db object pointer(*)
class Composite {
public:
Composite() {
}
#pragma db id
CompositeKey id;
};
Generated scheme is (for SQLite):
CREATE TABLE "Composite" (
"id_first" INTEGER NOT NULL,
"id_second" INTEGER NOT NULL);
I was expecting scheme like:
CREATE TABLE "Composite" (
"id_first" INTEGER NOT NULL,
"id_second" INTEGER NOT NULL,
PRIMARY KEY("id_first", "id_second"));
When generate ODB code for class which contains vector of Composite
pointer:
#pragma db object
class Container {
public:
Container() {
}
#pragma db id
int id;
std::vector<Composite* > values;
};
I got error: unable to map C++ type '::__gnu_cxx::new_allocator<
::Composite* >::value_type' used in data member 'values' to a database
type
Is possible to use composite value as primary key?
More information about the odb-users
mailing list