From b4d82730f640969ed92de915134ef28821d225ed Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 25 Sep 2012 09:43:18 -0400 Subject: [PATCH] Ensure that field definition of current class is used instead of identical field in parent class --- src/com/iciql/TableDefinition.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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 { 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 fields = Utils.newArrayList(); @@ -305,6 +318,7 @@ public class TableDefinition { classFields.addAll(Arrays.asList(superClass.getDeclaredFields())); } + Set uniqueFields = new LinkedHashSet(); T defaultObject = Db.instance(clazz); for (Field f : classFields) { // check if we should skip this field @@ -390,9 +404,11 @@ public class TableDefinition { fieldDef.defaultValue = defaultValue; fieldDef.enumType = enumType; fieldDef.dataType = ModelUtils.getDataType(fieldDef); - fields.add(fieldDef); + uniqueFields.add(fieldDef); } } + fields.addAll(uniqueFields); + List primaryKey = Utils.newArrayList(); int primitiveBoolean = 0; for (FieldDefinition fieldDef : fields) { -- 2.39.5