commit 719a0ba172cf5296c753ff2fd272b94366a09e9a
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Sun Jul 19 19:30:07 2015 +0200

    improvements

diff --git a/samples/example/Example.pro b/samples/example/Example.pro
index bc8b949..fda428c 100644
--- a/samples/example/Example.pro
+++ b/samples/example/Example.pro
@@ -25,7 +25,8 @@ SOURCES += \
     models/contact.cpp \
     models/faker/createfakemodeldata.cpp
 
-unix:!macx: LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug -lCuteEntityManager
+unix:!macx:CONFIG(debug, debug): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Debug -lCuteEntityManager
+else:unix:!macx:CONFIG(release, release): LIBS += -L$$PWD/../../../build-EntityManager-Desktop-Release/ -lCuteEntityManager
 unix:INCLUDEPATH += $$PWD/../../src
 unix:DEPENDPATH += $$PWD/../../src
 CONFIG += c++14
@@ -35,3 +36,5 @@ else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../build-EntityManag
 
 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
+
+
diff --git a/src/database.cpp b/src/database.cpp
index 48a2ab1..00860f0 100644
--- a/src/database.cpp
+++ b/src/database.cpp
@@ -126,7 +126,7 @@ bool Database::commitTransaction() {
 }
 
 bool Database::rollbackTransaction() {
-    qDebug() << "Transaction rolled back!";
+    qDebug() << "Transaction rolled back!" << this->database.lastError().text();
     return supportTransactions && this->database.rollback();
 }
 
diff --git a/src/entitymanager.cpp b/src/entitymanager.cpp
index 59316f2..cfaa37a 100644
--- a/src/entitymanager.cpp
+++ b/src/entitymanager.cpp
@@ -328,7 +328,6 @@ void EntityManager::savePostPersistedRelations(const QSharedPointer<Entity>
         }
         ++iterator;
     }
-
 }
 
 void EntityManager::persistMappedByRelation(const QList<QSharedPointer<Entity> >
@@ -340,6 +339,7 @@ void EntityManager::persistMappedByRelation(const QList<QSharedPointer<Entity> >
                                           || r.getCascadeType().contains(MERGE)
                                           || r.getCascadeType().contains(PERSIST) ? this->saveRelationEntities(list,
                                                   r) : list;
+    this->db->startTransaction();
     auto builder = this->schema->getQueryBuilder();
     q = builder->manyToManyInsert(tblName,
                                   builder->generateManyToManyColumnName(entity),
@@ -363,6 +363,9 @@ void EntityManager::persistMappedByRelation(const QList<QSharedPointer<Entity> >
             }
         }
     }
+    if (!this->db->commitTransaction()) {
+        this->db->rollbackTransaction();
+    }
 }
 
 
