Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 94bf67c7

Von Christian Ehringfeld vor fast 9 Jahren hinzugefügt

  • ID 94bf67c708c1655c33401c950d3ed9213c80b2a4
  • Vorgänger 7d60c5a2
  • Nachfolger af84b9c4

improvements

Unterschiede anzeigen:

src/entitymanager.cpp
}
bool EntityManager::executeQuery(const QString &query) {
return this->db->transaction(query);
return this->db->exec(query);
}
bool EntityManager::checkTable(const QSharedPointer<Entity> &entity) {
......
item = list.at(var);
if (item->getProperty(item->getPrimaryKey()).toLongLong() > -1) {
q.bindValue(1, item->getProperty(ptr->getPrimaryKey()));
q.exec();
this->schema->getDatabase()->exec(q);
if (prop.isReadable()) {
this->addEntityToListProperty(entity, ptr, prop);
} else {
qDebug() << "Query exec for many to many relation failed." <<
q.lastError().text();
qDebug() << "Involved entities: " << entity->getClassname() <<
"(MainEntitiy) and " << entity->getClassname();
"(MainEntitiy) and " << ptr->getClassname();
qDebug() << "Relation:" << r.getPropertyName();
}
}
......
|| r.getCascadeType().contains(CascadeType::ALL);
bool remove = r.getCascadeType().contains(CascadeType::REMOVE)
|| r.getCascadeType().contains(CascadeType::ALL);
if (q.exec()) {
if (this->schema->getDatabase()->exec(q)) {
for (int var = 0; var < list.size(); ++var) {
auto entity = list.at(var);
if (remove) {
......
QSqlQuery q = builder->manyToManyDelete(
tblName, builder->generateManyToManyColumnName(entity),
entity->getProperty(entity->getPrimaryKey()).toLongLong());
if (this->db->transaction(q)) {
if (this->db->exec(q)) {
auto nList = EntityInstanceFactory::castQVariantList(property);
this->persistMappedByRelation(nList, q, entity, ptr, r, tblName);
}
......
QList<QSqlQuery> q = this->schema->getQueryBuilder()->create(
entity);
bool first = true;
QVariant id = -1;
for (int var = 0; var < q.size(); ++var) {
auto query = q.at(var);
if (!first) {
this->schema->getQueryBuilder()->bindValue(entity->getPrimaryKey(), id, query);
}
rc = this->db->exec(query);
if (!rc) {
qDebug() << "Query failed:" << query.lastError().text() << " of class " <<
......
break;
}
if (first) {
entity->setProperty(entity->getPrimaryKey(), query.lastInsertId());
id = query.lastInsertId();
entity->setProperty(entity->getPrimaryKey(), id);
first = false;
}
}

Auch abrufbar als: Unified diff