commit 24c5480c79dfbbe30c36d75c8751b8b284cf59da
Author: Christian Ehringfeld <c.ehringfeld@t-online.de>
Date:   Sun Apr 12 16:33:37 2015 +0200

    ...

diff --git a/EntityManager.pro b/EntityManager.pro
index 90d4827..e42a6a5 100644
--- a/EntityManager.pro
+++ b/EntityManager.pro
@@ -25,7 +25,8 @@ src/entity.h \
     src/schema/mysqlschema.h \
     src/databasemigration.h \
     src/querybuilder.h \
-    src/schema/sqlitequerybuilder.h
+    src/schema/sqlitequerybuilder.h \
+    src/relation.h
 
 SOURCES += \
 src/entity.cpp \
@@ -38,7 +39,8 @@ src/entity.cpp \
     src/schema/mysqlschema.cpp \
     src/databasemigration.cpp \
     src/querybuilder.cpp \
-    src/schema/sqlitequerybuilder.cpp
+    src/schema/sqlitequerybuilder.cpp \
+    src/relation.cpp
 
 unix {
     target.path = /usr/lib
diff --git a/src/entity.cpp b/src/entity.cpp
index 582f8f6..ad458d9 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -33,16 +33,27 @@ QString Entity::getTablename() {
     return QString(this->metaObject()->className());
 }
 
+QList<Relation> Entity::getRelations() {
+    return QList<Relation>();
+}
+
 QStringList Entity::getTransientAttributes() {
     return QStringList();
 }
-qint64 Entity::getId() const
+
+QStringList Entity::getBLOBColumns() {
+    return QStringList();
+}
+
+QString Entity::getPrimaryKey() {
+    return "id";
+}
+qint32 Entity::getId() const
 {
     return id;
 }
 
-void Entity::setId(const qint64 &value)
+void Entity::setId(const qint32 &value)
 {
     id = value;
 }
-
diff --git a/src/entity.h b/src/entity.h
index f14e7bb..734b44e 100644
--- a/src/entity.h
+++ b/src/entity.h
@@ -21,12 +21,13 @@
 #include <QDebug>
 #include <QObject>
 #include "enums/databasetype.h"
+#include "relation.h"
 #include <QStringList>
 namespace CuteEntityManager {
 
 class Entity : public QObject {
     Q_OBJECT
-    Q_PROPERTY(qint64 firstName READ getId WRITE setId NOTIFY idChanged)
+    Q_PROPERTY(qint64 id READ getId WRITE setId NOTIFY idChanged)
 
   signals:
     void idChanged();
@@ -36,20 +37,22 @@ class Entity : public QObject {
     virtual QString toString();
     virtual ~Entity();
     virtual QString getTablename();
+    virtual QList<Relation> getRelations();
     /**
      * You should return the names of properties which should not persisted e.g. Properties which are only exposed to qml
      * @brief getTransientAttributes
      * @return
      */
     virtual QStringList getTransientAttributes();
-    //  virtual QMap<QString, QString> getManyToManyRelations() = 0;   //Key = Table, Value = joined Table Column
-    virtual qint64 getId() const;
-    virtual void setId(const qint64 &value);
+    virtual QStringList getBLOBColumns();
+    //return value must be the exact name defined in Q_PROPERTY
+    virtual QString getPrimaryKey();
 
-protected:
-    qint64 id;
+    qint32 getId() const;
+    void setId(const qint32 &value);
+
+  protected:
+    qint32 id;
 };
 }
-//Q_DECLARE_METATYPE(CuteEntityManager::Entity)
-//Q_DECLARE_METATYPE(CuteEntityManager::Entity*)
 #endif // ENTITY_H
diff --git a/src/entitymanager.h b/src/entitymanager.h
index bef9df1..7d803d2 100644
--- a/src/entitymanager.h
+++ b/src/entitymanager.h
@@ -31,6 +31,9 @@
 namespace CuteEntityManager {
 
 class EntityManager {
+  signals:
+    void actionFinished(qint64 id);
+
   private:
     static QStringList connectionNames;
     QSharedPointer<Schema> schema;
diff --git a/src/relation.cpp b/src/relation.cpp
new file mode 100644
index 0000000..d140cfb
--- /dev/null
+++ b/src/relation.cpp
@@ -0,0 +1,37 @@
+#include "relation.h"
+using namespace CuteEntityManager;
+
+Relation::Relation() {
+}
+
+Relation::Relation(QString propertyName, RelationType type, bool optional) {
+    this->propertyName = propertyName;
+    this->type = type;
+    this->optional = optional;
+}
+
+Relation::~Relation() {
+}
+
+RelationType Relation::getType() const {
+    return type;
+}
+
+void Relation::setType(const RelationType &value) {
+    type = value;
+}
+
+QString Relation::getPropertyName() const {
+    return propertyName;
+}
+
+void Relation::setPropertyName(const QString &value) {
+    propertyName = value;
+}
+bool Relation::getOptional() const {
+    return optional;
+}
+
+void Relation::setOptional(bool value) {
+    optional = value;
+}
diff --git a/src/relation.h b/src/relation.h
new file mode 100644
index 0000000..a7739a7
--- /dev/null
+++ b/src/relation.h
@@ -0,0 +1,34 @@
+#ifndef RELATION_H
+#define RELATION_H
+#include <QString>
+namespace CuteEntityManager {
+enum RelationType {
+    ONE_TO_ONE,
+    ONE_TO_MANY,
+    MANY_TO_MANY,
+    MANY_TO_ONE
+};
+
+class Relation {
+  public:
+    Relation();
+    Relation(QString propertyName, RelationType type, bool optional = true);
+    ~Relation();
+    RelationType getType() const;
+    void setType(const RelationType &value);
+
+    QString getPropertyName() const;
+    void setPropertyName(const QString &value);
+
+    bool getOptional() const;
+    void setOptional(bool value);
+
+  protected:
+    QString propertyName;
+    RelationType type;
+    bool optional;
+
+};
+}
+
+#endif // RELATION_H
diff --git a/src/schema.cpp b/src/schema.cpp
index 0118900..6514b91 100644
--- a/src/schema.cpp
+++ b/src/schema.cpp
@@ -35,6 +35,7 @@ QHash<QString, QString> Schema::getAbstractDatabaseTypes() {
     typeMap.insert("unsigned long long", TYPE_INTEGER);
     typeMap.insert("char",TYPE_CHAR);
     typeMap.insert("std::string", TYPE_TEXT);
+    typeMap.insert("std::wstring", TYPE_TEXT);
     typeMap.insert("QString", TYPE_TEXT);
     typeMap.insert("QVariant", TYPE_TEXT);
     typeMap.insert("QUuid", TYPE_TEXT);
diff --git a/src/schema.h b/src/schema.h
index f04b3bc..9c72673 100644
--- a/src/schema.h
+++ b/src/schema.h
@@ -12,6 +12,7 @@ class Schema {
   public:
     Schema(QSharedPointer<Database> database);
     virtual ~Schema();
+    //http://doc.qt.io/qt-5/sql-types.html
     const QString TYPE_PK = "pk";
     const QString TYPE_BIGPK = "bigpk";
     const QString TYPE_STRING = "string";
diff --git a/src/schema/mysqlschema.cpp b/src/schema/mysqlschema.cpp
index e09684e..1d62bf1 100644
--- a/src/schema/mysqlschema.cpp
+++ b/src/schema/mysqlschema.cpp
@@ -12,34 +12,23 @@
 
 //QHash<QString, QString> *MysqlSchema::getTypeMap() {
 //    if (this->typeMap.data()->empty()) {
-////        this->typeMap->data()->insert(TYPE_SMALLINT, 'tinyint');
-////        this->typeMap->data()->insert(TYPE_SMALLINT, 'bit');
-////        this->typeMap->data()->insert(TYPE_BOOLEAN, 'boolean');
-////        this->typeMap->data()->insert(TYPE_BOOLEAN, 'bool');
-////        this->typeMap->data()->insert(TYPE_SMALLINT, 'smallint');
-////        this->typeMap->data()->insert(TYPE_INTEGER, 'mediumint');
-////        this->typeMap->data()->insert(TYPE_INTEGER, 'int');
-////        this->typeMap->data()->insert(TYPE_INTEGER, 'integer');
-////        this->typeMap->data()->insert(TYPE_BIGINT, 'bigint');
-////        this->typeMap->data()->insert(TYPE_FLOAT, 'float');
-////        this->typeMap->data()->insert(TYPE_DOUBLE, 'double');
-////        this->typeMap->data()->insert(TYPE_FLOAT, 'real');
-////        this->typeMap->data()->insert(TYPE_DECIMAL, 'decimal');
-////        this->typeMap->data()->insert(TYPE_DECIMAL, 'numeric');
-////        this->typeMap->data()->insert(TYPE_TEXT, 'tinytext');
-////        this->typeMap->data()->insert(TYPE_TEXT, 'mediumtext');
-////        this->typeMap->data()->insert(TYPE_TEXT, 'longtext');
-////        this->typeMap->data()->insert(TYPE_TEXT, 'text');
-////        this->typeMap->data()->insert(TYPE_STRING, 'varchar');
-////        this->typeMap->data()->insert(TYPE_STRING, 'string');
-////        this->typeMap->data()->insert(TYPE_STRING, 'char');
-////        this->typeMap->data()->insert(TYPE_BINARY, 'blob');
-////        this->typeMap->data()->insert(TYPE_DATETIME, 'datetime');
-////        this->typeMap->data()->insert(TYPE_DATE, 'year');
-////        this->typeMap->data()->insert(TYPE_DATE, 'date');
-////        this->typeMap->data()->insert(TYPE_TIME, 'time');
-////        this->typeMap->data()->insert(TYPE_TIMESTAMP, 'timestamp');
-////        this->typeMap->data()->insert(TYPE_STRING, 'enum');
+//        this->typeMap.data()->insert(TYPE_SMALLINT, "tinyint");
+//        this->typeMap.data()->insert(TYPE_BOOLEAN, "boolean");
+//        this->typeMap.data()->insert(TYPE_SMALLINT, "smallint");
+//        this->typeMap.data()->insert(TYPE_INTEGER, "int");
+//        this->typeMap.data()->insert(TYPE_BIGINT, "bigint");
+//        this->typeMap.data()->insert(TYPE_FLOAT, "float");
+//        this->typeMap.data()->insert(TYPE_DOUBLE, "double");
+//        this->typeMap.data()->insert(TYPE_FLOAT, "real");
+//        this->typeMap.data()->insert(TYPE_DECIMAL, "decimal");
+//        this->typeMap.data()->insert(TYPE_TEXT, "text");
+//        this->typeMap.data()->insert(TYPE_STRING, "varchar");
+//        this->typeMap.data()->insert(TYPE_CHAR, "char");
+//        this->typeMap.data()->insert(TYPE_BINARY, "blob");
+//        this->typeMap.data()->insert(TYPE_DATETIME, "datetime");
+//        this->typeMap.data()->insert(TYPE_DATE, "date");
+//        this->typeMap.data()->insert(TYPE_TIME, "time");
+//        this->typeMap.data()->insert(TYPE_TIMESTAMP, "timestamp");
 //    }
 //    return this->typeMap.data();
 //}
