A realtion 1 to 1 is not created properly.
Dear all,
I'm new to this forum. My name is Joaquim Duran. Currently, I'm working with the version 1.2.4 BETA 17 in linux, using g++ 4.6.1.
I've written to classes with a relation 1 to 1 between them. I've no idea I've written something wrong, but I've the impression that the relation is not well implemented.
Class Appointment:
Class AbsInfo:
Sql sequence to create the table:
None of the tables contains have any external key.
Could you tell me how can I fix the problem?
Thanks and Best Regards,
Joaquim Duran
I'm new to this forum. My name is Joaquim Duran. Currently, I'm working with the version 1.2.4 BETA 17 in linux, using g++ 4.6.1.
I've written to classes with a relation 1 to 1 between them. I've no idea I've written something wrong, but I've the impression that the relation is not well implemented.
Class Appointment:
- Code: Select all
class AbsInfo;
class Appointment
{
QX_REGISTER_FRIEND_CLASS(Appointment)
public:
typedef boost::shared_ptr<AbsInfo> PtrAbsInfo;
Appointment();
virtual ~Appointment();
void set_id(long id) { m_id = id; };
long get_id() const { return m_id; };
void set_info(PtrAbsInfo info) { m_info = info; };
const PtrAbsInfo get_info() const { return m_info; };
PtrAbsInfo get_info() { return m_info; };
private:
long m_id;
PtrAbsInfo m_info;
};
QX_REGISTER_HPP_MY_TEST_EXE(Appointment, qx::trait::no_base_class_defined, 0)
- Code: Select all
QX_REGISTER_HPP_MY_TEST_EXE(Appointment, qx::trait::no_base_class_defined, 0)
typedef boost::shared_ptr<Appointment> PtrAppoint;
typedef qx::QxCollection<int, PtrAppoint> CollectionAppoint;
QX_REGISTER_CPP_MY_TEST_EXE(Appointment)
// Mapping to database
namespace qx
{
template <> void register_class(QxClass<Appointment> & t)
{
t.id(&Appointment::m_id, "cita_id");
t.relationOneToOne(&Appointment::m_info, "info_id");
}
}
// Class implementation
Appointment::Appointment():
m_id(0),
m_info()
{
}
Appointment::~Appointment()
{
}
Class AbsInfo:
- Code: Select all
class Appointment;
class AbsInfo
{
QX_REGISTER_FRIEND_CLASS(AbsInfo)
public:
enum Type
{
DICOM, // DICOM
HL7, // HL5
WEB_SERVICE // Gem Med Web service
};
typedef boost::shared_ptr<Appointment> PtrAppoint;
AbsInfo();
virtual ~AbsInfo();
void set_id(long id) { m_id = id; };
long get_id() const { return m_id; };
void set_appoint(PtrAppoint appoint) { m_appoint = appoint; };
const PtrAppoint get_appoint() const { return m_appoint; };
PtrAppoint get_appoint() { return m_appoint; };
private:
long m_id;
PtrAppoint m_appoint;
};
QX_REGISTER_HPP_MY_TEST_EXE(AbsInfo, qx::trait::no_base_class_defined, 0)
- Code: Select all
QX_REGISTER_CPP_MY_TEST_EXE(AbsInfo)
// Mapping to database
namespace qx
{
template <> void register_class(QxClass<AbsInfo> & t)
{
t.id(&AbsInfo::m_id, "info_id");
t.relationOneToOne(&AbsInfo::m_appoint, "appoint_id");
}
}
// Class implementation
AbsInfo::AbsInfo() :
m_id(0), m_appoint()
{
}
AbsInfo::~AbsInfo()
{
}
Sql sequence to create the table:
- Code: Select all
[QxOrm] sql query (107 ms) : CREATE TABLE Appointment (cita_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT)
[QxOrm] sql query (99 ms) : CREATE TABLE AbsInfo (info_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT)
None of the tables contains have any external key.
Could you tell me how can I fix the problem?
Thanks and Best Regards,
Joaquim Duran