qx::IxClass Instance Primary Key Dump
Posted: Fri Jan 06, 2017 9:46 pm
I'm not sure why but I can't successfully pull the primary key values from my objects. I've tried several approaches which are all consistent and wrong.
Values the following code examples produce are huge address like values. 194083216 The long-type value should have been a 3.
Thanks,
-SH
Values the following code examples produce are huge address like values. 194083216 The long-type value should have been a 3.
- Code: Select all
typedef QSharedPointer<qx::IxPersistable> QxObject_ptr;
QxObjectInfo::QxObjectInfo(const QxObject_ptr& obj)
{
if (!obj.isNull())
{
const qx::IxClass* ic = obj->qxClass();
if(ic)
{
qx::IxDataMemberX* icdmx = ic->getDataMemberX();
for (int i = 0; i < icdmx->count_WithDaoStrategy(); i++)
{
const qx::IxDataMember* icdm = icdmx->get_WithDaoStrategy(i);
if (icdm)
{
if (icdm->getIsPrimaryKey())
{
QString classType = ic->getKey();
key = icdm->toVariant(obj.data());
hash = classType % key.toString();
break;
}
}
}
}
}
}
- Code: Select all
typedef QSharedPointer<qx::IxPersistable> QxObject_ptr;
QxObjectInfo::QxObjectInfo(const QxObject_ptr& obj)
{
if (!obj.isNull())
{
const qx::IxClass* ic = obj->qxClass();
if(ic)
{
const qx::IxDataMember* idm = ic->getId(true);
if (idm)
{
QString classType = ic->getKey();
key = idm->toVariant(obj.data());
hash = classType % key.toString();
}
}
}
}
Thanks,
-SH