diff options
Diffstat (limited to 'src/com/iciql/TableDefinition.java')
-rw-r--r-- | src/com/iciql/TableDefinition.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java index bd61b16..f6a8c26 100644 --- a/src/com/iciql/TableDefinition.java +++ b/src/com/iciql/TableDefinition.java @@ -122,6 +122,19 @@ public class TableDefinition<T> { throw new IciqlException(e);
}
}
+
+ @Override
+ public int hashCode() {
+ return columnName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof FieldDefinition) {
+ return o.hashCode() == hashCode();
+ }
+ return false;
+ }
}
public ArrayList<FieldDefinition> fields = Utils.newArrayList();
@@ -305,6 +318,7 @@ public class TableDefinition<T> { classFields.addAll(Arrays.asList(superClass.getDeclaredFields()));
}
+ Set<FieldDefinition> uniqueFields = new LinkedHashSet<FieldDefinition>();
T defaultObject = Db.instance(clazz);
for (Field f : classFields) {
// check if we should skip this field
@@ -390,9 +404,11 @@ public class TableDefinition<T> { fieldDef.defaultValue = defaultValue;
fieldDef.enumType = enumType;
fieldDef.dataType = ModelUtils.getDataType(fieldDef);
- fields.add(fieldDef);
+ uniqueFields.add(fieldDef);
}
}
+ fields.addAll(uniqueFields);
+
List<String> primaryKey = Utils.newArrayList();
int primitiveBoolean = 0;
for (FieldDefinition fieldDef : fields) {
|