Revision 6d91d381
Von Christian Ehringfeld vor mehr als 10 Jahren hinzugefügt
| src/entitymanager.cpp | ||
|---|---|---|
|
const bool refresh) {
|
||
|
QSharedPointer<Entity> r;
|
||
|
if (!e.isNull()) {
|
||
|
if (refresh || ((r = this->cache.get(id, QString(e.data()->getClassname())))
|
||
|
&& !r.data())) {
|
||
|
auto map = this->findByPk(e);
|
||
|
if (refresh || !(r = this->cache.get(id, QString(e.data()->getClassname())))) {
|
||
|
e.data()->setId(id);
|
||
|
auto map = this->findByPk(id, e);
|
||
|
r = this->convert(map, e->getClassname(), refresh);
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
QSqlQuery q = this->schema.data()->getQueryBuilder().data()->create(entity);
|
||
|
rc = this->db->transaction(q);
|
||
|
if (rc) {
|
||
|
entity.data()->setId(this->schema.data()->getLastInsertID().toLongLong(&rc));
|
||
|
entity.data()->setId(q.lastInsertId().toLongLong(&rc));
|
||
|
if (persistRelations) {
|
||
|
this->saveRelations(entity);
|
||
|
}
|
||
| ... | ... | |
|
return EntityManager::connectionNames;
|
||
|
}
|
||
|
|
||
|
QHash<QString, QVariant> EntityManager::findByPk(const QSharedPointer<Entity>
|
||
|
QHash<QString, QVariant> EntityManager::findByPk(qint64 id,
|
||
|
const QSharedPointer<Entity>
|
||
|
&e) {
|
||
|
QSqlQuery q = this->schema.data()->getQueryBuilder().data()->find(e);
|
||
|
QSqlQuery q = this->schema.data()->getQueryBuilder().data()->find(id, e);
|
||
|
auto listMap = this->convertQueryResult(q);
|
||
|
if (!listMap.isEmpty()) {
|
||
|
return listMap.at(0);
|
||
Auch abrufbar als: Unified diff
some bug fixes, caching works