long insert(Db db, Object obj, boolean returnKey) {
		if (!StringUtils.isNullOrEmpty(viewTableName)) {
			throw new IciqlException("Iciql does not support inserting rows into views!");
		}
		SQLStatement stat = new SQLStatement(db);
		StatementBuilder buff = new StatementBuilder("INSERT INTO ");
		buff.append(db.getDialect().prepareTableName(schemaName, tableName)).append('(');
		for (FieldDefinition field : fields) {
			if (skipInsertField(field, obj)) {
				continue;
			}
			buff.appendExceptFirst(", ");
			buff.append(db.getDialect().prepareColumnName(field.columnName));
		}
		buff.append(") VALUES(");
		buff.resetCount();
		for (FieldDefinition field : fields) {
			if (skipInsertField(field, obj)) {
				continue;
			}
			buff.appendExceptFirst(", ");
			buff.append('?');
			Object value = getValue(obj, field);
			if (value == null && !field.nullable) {
				// try to interpret and instantiate a default value
				value = ModelUtils.getDefaultValue(field, db.getDialect().getDateTimeClass());
			}
			stat.addParameter(value);
		}
		buff.append(')');
		stat.setSQL(buff.toString());
		IciqlLogger.insert(stat.getSQL());
		if (returnKey) {
			return stat.executeInsert();
		}
		return stat.executeUpdate();
	}