Revision 033279c9
Von Sebastian Diel vor mehr als 9 Jahren hinzugefügt
src/entityinstancefactory.cpp | ||
---|---|---|
Entity *e = 0;
|
||
if (metaTypeId != QMetaType::UnknownType) {
|
||
auto metaObject = QMetaType::metaObjectForType(metaTypeId);
|
||
e = static_cast<Entity *>(metaObject->newInstance());
|
||
if(metaObject) {
|
||
e = qobject_cast<Entity*>(metaObject->newInstance());
|
||
} else {
|
||
void* newObj = QMetaType::create(metaTypeId);
|
||
if(newObj) {
|
||
e = static_cast<Entity *>(newObj);
|
||
}
|
||
}
|
||
|
||
if (!e) {
|
||
qDebug() << "Entity instance could not created!";
|
||
throw - 2; //testing
|
src/querybuilder.cpp | ||
---|---|---|
if (!rc) {
|
||
QSqlQuery q = this->database.data()->getQuery(this->createTable(tableName,
|
||
tableDefinition));
|
||
|
||
|
||
if (this->database.data()->transaction(q)) {
|
||
if(createRelationTables) {
|
||
auto relTables = this->generateRelationTables(entity);
|
||
auto i = relTables.constBegin();
|
||
while(i != relTables.constEnd()) {
|
||
this->createTable(i.key(),i.value());
|
||
auto query = this->database.data()->getQuery(this->createTable(i.key(),i.value()));
|
||
this->database.data()->exec(query);
|
||
++i;
|
||
}
|
||
}
|
||
... | ... | |
this->schema.data()->TYPE_BIGINT);
|
||
auto meta = props.value(r.getPropertyName());
|
||
QSharedPointer<Entity> ptr = QSharedPointer<Entity>
|
||
(EntityInstanceFactory::createInstance(meta.enclosingMetaObject()));
|
||
(EntityInstanceFactory::createInstance(EntityInstanceFactory::extractEntityType(QMetaType::typeName(meta.userType()))));
|
||
h.insert(this->generateManyToManyColumnName(ptr),
|
||
this->schema.data()->TYPE_BIGINT);
|
||
relations.insert(this->generateManyToManyTableName(entity, ptr), h);
|
||
... | ... | |
this->saveAttributes(entity, this->processProperties(e, usedProperties),
|
||
this->processRelations(e, usedRelations)), e.data()->getPrimaryKey()));
|
||
} else {
|
||
qDebug() << "Instance of " << metaObj->className() << " could not created";
|
||
qDebug() << "Instance of " << metaObj->className() << " could not be created";
|
||
break;
|
||
}
|
||
}
|
src/relation.cpp | ||
---|---|---|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||
*/
|
||
#include "relation.h"
|
||
#include <QDebug>
|
||
using namespace CuteEntityManager;
|
||
|
||
Relation::Relation() {
|
||
}
|
||
|
||
Relation::Relation(QString propertyName, RelationType type, bool optional) {
|
||
Relation::Relation(QString propertyName, bool optional, RelationType type) {
|
||
this->propertyName = propertyName;
|
||
this->type = type;
|
||
this->optional = optional;
|
src/relation.h | ||
---|---|---|
|
||
class Relation {
|
||
public:
|
||
Relation();
|
||
Relation(QString propertyName, RelationType type, bool optional = true);
|
||
explicit Relation();
|
||
explicit Relation(QString propertyName, bool optional, RelationType type);
|
||
/**
|
||
* @brief Relation
|
||
* @param propertyName
|
||
* @param type
|
||
* @param mappedBy Q_PROPERTY in foreign Entity
|
||
*/
|
||
Relation(QString propertyName, RelationType type, QString mappedBy,
|
||
explicit Relation(QString propertyName, RelationType type, QString mappedBy,
|
||
QList<CascadeType> cascadeType = {MERGE, PERSIST, REFRESH});
|
||
~Relation();
|
||
RelationType getType() const;
|
Auch abrufbar als: Unified diff
brainfuck