Unidentified Programmed Object
- MySql Connector/C++ http://dev.mysql.com/downloads/connector/cpp/ http://dev.mysql.com/tech-resources/articles/building-mysql-connector-cpp.html
- MySql compiling dependancies mysql-client mysql-server libmysqlclient-dev
- In order to compile the MySql connector, add
#include <stdint.h>
incppconn/resultset.h
#include <stdint.h>
indriver/nativeapi/native_connection_wrapper.h
#include <stdint.h>
indriver/nativeapi/native_statement_wrapper.h
#include <stdint.h>
indriver/nativeapi/native_resultset_wrapper.h
First, declare the relations of your new entity :
class ParentOf : public OneToMany<Person,Person> { };
class ChildOf : public ManyToOne<Person,Person>
{
// LMANDATORY specifies that a Person has to be the child of someone
static const Cardinality __cardinality__ = OneToMany<Person,Person>::__cardinality__ | LMANDATORY;
};
Next, declare the Person
entity :
class Person : public Entity
{
public:
StrAttribute name;
ParentOf parent_of;
ChildOf child_of;
};
And make some calls :
Person bob = Person(42); // Get the Person with id 42
Person kevin = Person(); // Create a new entity Person
kevin.name = "Kevin";
kevin.child_of = bob;
kevin.commit();
bob.parent_of += kevin;
bob.commit()