+/*
+ * Copyright (C) 2010 Ixonos Plc.
+ * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ *
+ * This file is part of ConfClerk.
+ *
+ * ConfClerk is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * ConfClerk is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ConfClerk. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef ORMRECORD_H
#define ORMRECORD_H
class OrmException
{
+public:
+ OrmException(const QString& text) : mText(text) {}
+ virtual ~OrmException(){}
+ virtual const QString& text() const { return mText; }
+private:
+ QString mText;
};
-class OrmNoObjectException : OrmException
+class OrmNoObjectException : public OrmException
{
+public:
+ OrmNoObjectException() : OrmException("No object exception"){}
+ ~OrmNoObjectException(){}
};
-class OrmSqlException : OrmException
+class OrmSqlException : public OrmException
{
public:
- OrmSqlException(const QString& text) : mText(text) {}
- QString text() const { return mText; }
-
-private:
- QString mText;
+ OrmSqlException(const QString& text) : OrmException( QString("Sql error: ") + text ) {}
+ ~OrmSqlException(){}
};
template <typename T>
qDebug() << "Error: " << query.lastError().driverText() << "; Type: " << query.lastError().type();
throw OrmSqlException(query.lastError().text());
}
- else
- {
- qDebug() << "SQL OK";
- }
}
QList<T> objects;
{
objects << hydrate(query.record());
}
- qDebug() << "Fetch done";
return objects;
}
QSqlRecord OrmRecord<T>::toRecord(const QList<QSqlField> & columnList)
{
QSqlRecord record;
- foreach (const QSqlField & col, columnList)
+ for(int i=0; i< columnList.count(); i++)
{
- record.append(col);
+ record.append(columnList[i]);
}
return record;
}