- Code: Select all
class SpBaseORM
{
QX_REGISTER_FRIEND_CLASS(SpBaseORM)
friend struct qx::dao::detail::QxDao_Trigger<SpBaseORM>;
protected:
QString m_uuid;
QDateTime m_createdDate;
public:
SpBaseORM();
SpBaseORM(const QString & id);
virtual ~SpBaseORM();
QString GetUuid() const;
QDateTime GetCreatedDate() const;
void SetUuid(const QString & val);
void SetCreatedDate(const QDateTime & val);
static QString ColumnUuid() { return "uuid"; }
static QString ColumnCreatedDate() { return "created_date"; }
};
typedef QSharedPointer<SpBaseORM> SpBaseORMPtr;
typedef qx::QxCollection<QString, SpBaseORMPtr> SpBaseORMList;
typedef QSharedPointer<SpBaseORMList> SpBaseORMListPtr;
QX_REGISTER_ABSTRACT_CLASS(SpBaseORM)
QX_REGISTER_PRIMARY_KEY(SpBaseORM, QString)
QX_REGISTER_HPP_DATABASEMODELS(SpBaseORM, qx::trait::no_base_class_defined, 0)
- Code: Select all
QX_REGISTER_CPP_DATABASEMODELS(SpBaseORM)
namespace qx {
template <>
void register_class(QxClass<SpBaseORM> & t)
{
qx::IxDataMember * pData = NULL; Q_UNUSED(pData);
qx::IxSqlRelation * pRelation = NULL; Q_UNUSED(pRelation);
qx::IxFunction * pFct = NULL; Q_UNUSED(pFct);
qx::IxValidator * pValidator = NULL; Q_UNUSED(pValidator);
t.setSoftDelete(qx::QxSoftDelete("deleted"));
pData = t.id(& SpBaseORM::m_uuid, "uuid", 0);
pData = t.data(& SpBaseORM::m_createdDate, "createdDate", 0, true, true);
pData->setName("created_date");
qx::QxValidatorX<SpBaseORM> * pAllValidator = t.getAllValidator(); Q_UNUSED(pAllValidator);
}
} // namespace qx
SpBaseORM::SpBaseORM() { ; }
SpBaseORM::SpBaseORM(const QString & id) : m_uuid(id) { ; }
SpBaseORM::~SpBaseORM() { ; }
QString SpBaseORM::GetUuid() const { return m_uuid; }
QDateTime SpBaseORM::GetCreatedDate() const { return m_createdDate; }
void SpBaseORM::SetUuid(const QString & val) { m_uuid = val; }
void SpBaseORM::SetCreatedDate(const QDateTime & val) { m_createdDate = val; }
and the derived class:
- Code: Select all
class DATABASEMODELSSHARED_EXPORT SpPatientORM : public SpBaseORM
{
QX_REGISTER_FRIEND_CLASS(SpPatientORM)
protected:
QString m_name;
public:
SpPatientORM();
SpPatientORM(const QString & id);
virtual ~SpPatientORM();
QString GetName() const;
void SetName(const QString & val);
public:
static QString ColumnName() { return "name"; }
static QString ColumnUuid() { return "uuid"; }
static QString ColumnCreatedDate() { return "created_date"; }
public:
static QString TableName() { return "t_patient"; }
};
typedef QSharedPointer<SpPatientORM> SpPatientORMPtr;
typedef qx::QxCollection<QString, SpPatientORMPtr> SpPatientORMList;
typedef QSharedPointer<SpPatientORMList> SpPatientORMListPtr;
QX_REGISTER_PRIMARY_KEY(SpPatientORM, QString)
QX_REGISTER_HPP_DATABASEMODELS(SpPatientORM, SpBaseORM, 0)
- Code: Select all
QX_REGISTER_CPP_DATABASEMODELS(SpPatientORM)
namespace qx {
template <>
void register_class(QxClass<SpPatientORM> & t)
{
qx::IxDataMember * pData = NULL; Q_UNUSED(pData);
qx::IxSqlRelation * pRelation = NULL; Q_UNUSED(pRelation);
qx::IxFunction * pFct = NULL; Q_UNUSED(pFct);
qx::IxValidator * pValidator = NULL; Q_UNUSED(pValidator);
t.setName("t_patient");
t.setSoftDelete(qx::QxSoftDelete("deleted"));
pData = t.data(& SpPatientORM::m_name, "name", 0, true, true);
pData->setIsIndex(true);
qx::QxValidatorX<SpPatientORM> * pAllValidator = t.getAllValidator(); Q_UNUSED(pAllValidator);
}
} // namespace qx
SpPatientORM::SpPatientORM() : SpBaseORM() { ; }
SpPatientORM::SpPatientORM(const QString & id) : SpBaseORM(id) { ; }
SpPatientORM::~SpPatientORM() { ; }
QString SpPatientORM::GetName() const { return m_name; }
void SpPatientORM::SetName(const QString & val) { m_name = val; }
when update with list of colume's name
- Code: Select all
SpPatientORM patient;
patient2.setuuid("b");
patient2.setname("c");
QStringList columns;
columns.append("name");
columns.append("created_date");
QSqlError daoError=qx::dao::update(patient,0,columns);
show the message:
ASSERT failure in [QxOrm] qx::QxSqlQueryBuilder<T>::verifyColumns(): "column 'created_date' not found in table 't_patient'"
But I'm sure that exist colume 'created_date' in the 't_patient'.
Any advice to fixed it ?