本文整理汇总了C++中TSqlORMapper::findFirst方法的典型用法代码示例。如果您正苦于以下问题:C++ TSqlORMapper::findFirst方法的具体用法?C++ TSqlORMapper::findFirst怎么用?C++ TSqlORMapper::findFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TSqlORMapper
的用法示例。
在下文中一共展示了TSqlORMapper::findFirst方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: store
bool TSessionSqlObjectStore::store(TSession &session)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
TSessionObject so = mapper.findFirst(cri);
#ifndef TF_NO_DEBUG
{
QByteArray badummy;
QDataStream dsdmy(&badummy, QIODevice::ReadWrite);
dsdmy << *static_cast<const QVariantMap *>(&session);
TSession dummy;
dsdmy.device()->seek(0);
dsdmy >> *static_cast<QVariantMap *>(&dummy);
if (dsdmy.status() != QDataStream::Ok) {
tSystemError("Failed to store a session into the cookie store. Must set objects that can be serialized.");
}
}
#endif
QDataStream ds(&so.data, QIODevice::WriteOnly);
ds << *static_cast<const QVariantMap *>(&session);
if (ds.status() != QDataStream::Ok) {
tSystemError("Failed to store session. Must set objects that can be serialized.");
return false;
}
if (so.isNull()) {
so.id = session.id();
return so.create();
}
return so.update();
}
示例2: get
ParkAttendants ParkAttendants::get(int id, int lockRevision)
{
TSqlORMapper<ParkAttendantsObject> mapper;
TCriteria cri;
cri.add(ParkAttendantsObject::Id, id);
cri.add(ParkAttendantsObject::LockRevision, lockRevision);
return ParkAttendants(mapper.findFirst(cri));
}
示例3: get
RefPackingDef RefPackingDef::get(const QString &createdBy, const QString &updatedBy)
{
TCriteria cri;
cri.add(RefPackingDefObject::CreatedBy, createdBy);
cri.add(RefPackingDefObject::UpdatedBy, updatedBy);
TSqlORMapper<RefPackingDefObject> mapper;
return RefPackingDef(mapper.findFirst(cri));
}
示例4: get
ChatLog ChatLog::get(int id, int lockRevision)
{
TSqlORMapper<ChatLogObject> mapper;
TCriteria cri;
cri.add(ChatLogObject::Id, id);
cri.add(ChatLogObject::LockRevision, lockRevision);
return ChatLog(mapper.findFirst(cri));
}
示例5: get
Vehicles Vehicles::get(int id, int lockRevision)
{
TSqlORMapper<VehiclesObject> mapper;
TCriteria cri;
cri.add(VehiclesObject::Id, id);
cri.add(VehiclesObject::LockRevision, lockRevision);
return Vehicles(mapper.findFirst(cri));
}
示例6: get
UserVehicle UserVehicle::get(int id, int lockRevision)
{
TSqlORMapper<UserVehicleObject> mapper;
TCriteria cri;
cri.add(UserVehicleObject::Id, id);
cri.add(UserVehicleObject::LockRevision, lockRevision);
return UserVehicle(mapper.findFirst(cri));
}
示例7: removeOldLogs
void ChatLog::removeOldLogs(int remainingCount)
{
int del = count() - remainingCount;
if (del > 0) {
TSqlORMapper<ChatLogObject> mapper;
mapper.setSortOrder(ChatLogObject::Id, Tf::DescendingOrder);
auto log = mapper.findFirst();
int maxId = log.id;
TCriteria ctr(ChatLogObject::Id, TSql::LessEqual, maxId - remainingCount);
mapper.removeAll(ctr);
}
}
示例8: store
bool TSessionSqlObjectStore::store(TSession &session)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
TSessionObject so = mapper.findFirst(cri);
QDataStream ds(&so.data, QIODevice::WriteOnly);
ds << *static_cast<const QVariantHash *>(&session);
if (so.isEmpty()) {
so.id = session.id();
return so.create();
}
return so.update();
}
示例9: find
TSession TSessionSqlObjectStore::find(const QByteArray &id, const QDateTime &modified)
{
TSqlORMapper<TSessionObject> mapper;
TCriteria cri;
cri.add(TSessionObject::Id, TSql::Equal, id);
cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);
TSessionObject sess = mapper.findFirst(cri);
if (sess.isEmpty())
return TSession();
TSession result(id);
QDataStream ds(&sess.data, QIODevice::ReadOnly);
ds >> *static_cast<QVariantHash *>(&result);
return result;
}
示例10: find
TSession TSessionSqlObjectStore::find(const QByteArray &id)
{
QDateTime modified = QDateTime::currentDateTime().addSecs(-lifeTimeSecs());
TSqlORMapper<TSessionObject> mapper;
TCriteria cri;
cri.add(TSessionObject::Id, TSql::Equal, id);
cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);
TSessionObject so = mapper.findFirst(cri);
if (so.isNull()) {
return TSession();
}
TSession session(id);
QDataStream ds(&so.data, QIODevice::ReadOnly);
ds >> *static_cast<QVariantMap *>(&session);
if (ds.status() != QDataStream::Ok) {
tSystemError("Failed to load a session from the sqlobject store.");
}
return session;
}
示例11: get
VMenusGroupMenuRole VMenusGroupMenuRole::get(int roleId, int menusGroupOrder, int menusGroupId, const QString &menusGroupCd, const QString &menusGroupNameZh, const QString &menusGroupNameEn, const QString &menusGroupTooltip, const QString &menusGroupDesc, int menuId, int menuOrder, const bool &breakBool, const QString &menuCd, const QString &menuNameZh, const QString &menuNameEn, const QString &menuTooltip, const QString &menuDesc, const QString &controller, const QString &action)
{
TCriteria cri;
cri.add(VMenusGroupMenuRoleObject::RoleId, roleId);
cri.add(VMenusGroupMenuRoleObject::MenusGroupOrder, menusGroupOrder);
cri.add(VMenusGroupMenuRoleObject::MenusGroupId, menusGroupId);
cri.add(VMenusGroupMenuRoleObject::MenusGroupCd, menusGroupCd);
cri.add(VMenusGroupMenuRoleObject::MenusGroupNameZh, menusGroupNameZh);
cri.add(VMenusGroupMenuRoleObject::MenusGroupNameEn, menusGroupNameEn);
cri.add(VMenusGroupMenuRoleObject::MenusGroupTooltip, menusGroupTooltip);
cri.add(VMenusGroupMenuRoleObject::MenusGroupDesc, menusGroupDesc);
cri.add(VMenusGroupMenuRoleObject::MenuId, menuId);
cri.add(VMenusGroupMenuRoleObject::MenuOrder, menuOrder);
cri.add(VMenusGroupMenuRoleObject::BreakBool, breakBool);
cri.add(VMenusGroupMenuRoleObject::MenuCd, menuCd);
cri.add(VMenusGroupMenuRoleObject::MenuNameZh, menuNameZh);
cri.add(VMenusGroupMenuRoleObject::MenuNameEn, menuNameEn);
cri.add(VMenusGroupMenuRoleObject::MenuTooltip, menuTooltip);
cri.add(VMenusGroupMenuRoleObject::MenuDesc, menuDesc);
cri.add(VMenusGroupMenuRoleObject::Controller, controller);
cri.add(VMenusGroupMenuRoleObject::Action, action);
TSqlORMapper<VMenusGroupMenuRoleObject> mapper;
return VMenusGroupMenuRole(mapper.findFirst(cri));
}