Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我创建了一个新对象,设置了值(包括 ID/PK),但是当我使用 qx::dao::insert 时,它会忽略我指定的 ID。
如何指定要保留的行的 PK 值?
我认为您已将主键定义为自动增量(这是使用 QxOrm 库的数字类型的默认值)。如果您想在将实例插入数据库之前自己定义主键,请像这样注册您的 ID:
template <> void register_class(QxClass<MyClass> & t) { qx::IxDataMember * pId = t.id(& MyClass::m_my_id, "my_id"); pId->setAutoIncrement(false); // etc... }