Revision f6a3fe0a
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/simple/Example.pro | ||
---|---|---|
#-------------------------------------------------
|
||
#
|
||
# Project created by QtCreator 2013-08-01T15:03:24
|
||
#
|
||
#-------------------------------------------------
|
||
|
||
QT += core
|
||
QT += sql
|
||
|
||
QT -= gui
|
||
|
||
#TARGET = EntityManager
|
||
CONFIG += console
|
||
CONFIG -= app_bundle
|
||
|
||
TEMPLATE = app
|
||
|
||
HEADERS += \
|
||
artikel.h
|
||
|
||
SOURCES += \
|
||
main.cpp \
|
||
artikel.cpp
|
||
|
||
unix:!macx: LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug -lCuteEntityManager
|
||
unix:INCLUDEPATH += $$PWD/../../src
|
||
unix:DEPENDPATH += $$PWD/../../src
|
||
CONFIG += c++14
|
||
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/release/ -lCuteEntityManager
|
||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug/ -lCuteEntityManager
|
||
|
||
win32:INCLUDEPATH += $$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug
|
||
win32:DEPENDPATH += $$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug
|
samples/simple/Simple.pro | ||
---|---|---|
#-------------------------------------------------
|
||
#
|
||
# Project created by QtCreator 2013-08-01T15:03:24
|
||
#
|
||
#-------------------------------------------------
|
||
|
||
QT += core
|
||
QT += sql
|
||
|
||
QT -= gui
|
||
|
||
#TARGET = EntityManager
|
||
CONFIG += console
|
||
CONFIG -= app_bundle
|
||
|
||
TEMPLATE = app
|
||
|
||
HEADERS += \
|
||
artikel.h
|
||
|
||
SOURCES += \
|
||
main.cpp \
|
||
artikel.cpp
|
||
|
||
unix:!macx: LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug -lCuteEntityManager
|
||
unix:INCLUDEPATH += $$PWD/../../src
|
||
unix:DEPENDPATH += $$PWD/../../src
|
||
CONFIG += c++14
|
||
|
||
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/release/ -lCuteEntityManager
|
||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug/ -lCuteEntityManager
|
||
|
||
win32:INCLUDEPATH += $$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug
|
||
win32:DEPENDPATH += $$PWD/../../build-EntityManager-Desktop_Qt_5_4_1_MinGW_32bit-Debug/debug
|
src/entitymanager.cpp | ||
---|---|---|
|
||
bool EntityManager::canPersistRelation(const Relation &relation,
|
||
const RelationType &r, const QVariant &var) const {
|
||
return relation.getType() == r
|
||
&& var.canConvert<QList<QSharedPointer<Entity>>>();
|
||
return relation.getType() == r && var.canConvert<QVariantList>();
|
||
}
|
||
|
||
void EntityManager::setListProperty(const QSharedPointer<Entity> &entity,
|
||
... | ... | |
|
||
void EntityManager::persistManyToMany(const QSharedPointer<Entity> &entity,
|
||
const Relation &r, const QVariant &property) {
|
||
QList<QSharedPointer<Entity>> list =
|
||
qvariant_cast<QList<QSharedPointer<Entity>>>(property);
|
||
auto list = property.value<QList<QVariant>>();
|
||
if (!list.isEmpty()) {
|
||
auto ptr = list.at(0);
|
||
/**
|
||
* TODO
|
||
*/
|
||
auto ptr = list.at(0).value<QSharedPointer<Entity>>();
|
||
auto builder = this->schema.data()->getQueryBuilder();
|
||
QString tblName = builder.data()->generateManyToManyTableName(entity, ptr);
|
||
if (this->schema.data()->getTables().contains(tblName)) {
|
||
... | ... | |
tblName, builder.data()->generateManyToManyColumnName(entity),
|
||
entity.data()->property(entity.data()->getPrimaryKey()).toLongLong());
|
||
if (this->db.data()->transaction(q)) {
|
||
this->persistMappedByRelation(list, q, entity, r, tblName);
|
||
//this->persistMappedByRelation(list, q, entity, r, tblName);
|
||
}
|
||
} else {
|
||
qDebug() << "MANY_TO_MANY Table " << tblName << " not exists";
|
Auch abrufbar als: Unified diff
wip