Revision a473cd61
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
src/entitymanager.cpp | ||
---|---|---|
if (r.getType() == RelationType::MANY_TO_ONE) {
|
||
auto e = EntityInstanceFactory::castQVariant(var);
|
||
if (this->shouldBeSaved(e, r)) {
|
||
this->save(e);
|
||
this->save(e, true, false);
|
||
auto fkProp = EntityHelper::mappedProperty(r, e);
|
||
if (fkProp.isValid()) {
|
||
EntityHelper::addEntityToListProperty(e, entity, fkProp);
|
||
... | ... | |
} else if (r.getType() == RelationType::ONE_TO_ONE
|
||
&& r.getMappedBy().isEmpty()) {
|
||
auto e = EntityInstanceFactory::castQVariant(var);
|
||
this->save(e);
|
||
this->save(e, true, false);
|
||
auto prop = EntityHelper::mappedProperty(r, e);
|
||
if (prop.isValid()) {
|
||
EntityHelper::setProperty(e, entity, prop);
|
||
... | ... | |
for (int var = 0; var < list.size(); ++var) {
|
||
auto e = list.at(var);
|
||
if (this->shouldBeSaved(e, r)) {
|
||
this->save(e);
|
||
this->save(e, true, false);
|
||
if (fkProp.isValid()) {
|
||
EntityHelper::addEntityToListProperty(e, entity, fkProp);
|
||
}
|
||
... | ... | |
} else if (r.getType() == RelationType::ONE_TO_ONE
|
||
&& !r.getMappedBy().isEmpty()) {
|
||
auto e = EntityInstanceFactory::castQVariant(var);
|
||
this->save(e);
|
||
if (this->hasChanged(e)) {
|
||
this->save(e, true, false);
|
||
}
|
||
auto fkProp = EntityHelper::mappedProperty(r, e);
|
||
if (fkProp.isValid()) {
|
||
EntityHelper::addEntityToListProperty(e, entity, fkProp);
|
||
... | ... | |
QSharedPointer<Entity> ptr;
|
||
for (int var = 0; var < list.size(); ++var) {
|
||
ptr = list.at(var);
|
||
if (this->shouldBeSaved(ptr, r) && this->hasChanged(ptr) && this->save(ptr)) {
|
||
if ((this->shouldBeSaved(ptr, r) && this->save(ptr, true, false))
|
||
|| ptr->getProperty(ptr->getPrimaryKey()).toLongLong() > -1) {
|
||
saved.append(ptr);
|
||
}
|
||
}
|
||
... | ... | |
}
|
||
|
||
bool EntityManager::save(QSharedPointer<Entity> &entity,
|
||
const bool persistRelations) {
|
||
if (entity->getProperty(entity->getPrimaryKey()).toLongLong() > -1) {
|
||
return this->merge(entity, persistRelations);
|
||
} else {
|
||
return this->create(entity, persistRelations);
|
||
const bool persistRelations, const bool ignoreHasChanged) {
|
||
if (ignoreHasChanged || (!ignoreHasChanged && this->hasChanged(entity))) {
|
||
if (entity->getProperty(entity->getPrimaryKey()).toLongLong() > -1) {
|
||
return this->merge(entity, persistRelations);
|
||
} else {
|
||
return this->create(entity, persistRelations);
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
qint64 EntityManager::findId(QSharedPointer<Entity> &entity) {
|
Auch abrufbar als: Unified diff
more stuff for #578