summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2012-09-25 09:43:18 -0400
committerJames Moger <james.moger@gmail.com>2012-09-25 09:43:18 -0400
commitb4d82730f640969ed92de915134ef28821d225ed (patch)
tree48f40d04b3a4eb756a9a8381731d19926f90665f /src
parentb4c987d43004727b860b5b4cd1b6d24fe4c5e361 (diff)
downloadiciql-b4d82730f640969ed92de915134ef28821d225ed.tar.gz
iciql-b4d82730f640969ed92de915134ef28821d225ed.zip
Ensure that field definition of current class is used instead of identical field in parent class
Diffstat (limited to 'src')
-rw-r--r--src/com/iciql/TableDefinition.java18
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) {