this.dao = dao;
this.dataClass = tableConfig.getDataClass();
this.tableName = tableConfig.getTableName();
this.fieldTypes = tableConfig.getFieldTypes(databaseType);
// find the id field
FieldType findIdFieldType = null;
for (FieldType fieldType : fieldTypes) {
if (fieldType.isId() || fieldType.isGeneratedId() || fieldType.isGeneratedIdSequence()) {
if (findIdFieldType != null) {
throw new SQLException("More than 1 idField configured for class " + dataClass + " ("
+ findIdFieldType + "," + fieldType + ")");
}
findIdFieldType = fieldType;
}
}
// if we just have 1 field and it is a generated-id then inserts will be blank which is not allowed.
if (fieldTypes.length == 1 && findIdFieldType != null && findIdFieldType.isGeneratedId()) {
throw new SQLException("Must have more than a single field which is a generated-id for class " + dataClass);
}
// can be null if there is no id field
this.idField = findIdFieldType;
this.constructor = tableConfig.getConstructor();