]> source.dussan.org Git - iciql.git/commitdiff
Ensure that field definition of current class is used instead of identical field...
authorJames Moger <james.moger@gmail.com>
Tue, 25 Sep 2012 13:43:18 +0000 (09:43 -0400)
committerJames Moger <james.moger@gmail.com>
Tue, 25 Sep 2012 13:43:18 +0000 (09:43 -0400)
src/com/iciql/TableDefinition.java

index bd61b16bd1cf8609f869dab296c2b66493ed6b9f..f6a8c26c776af5669c0baa6856e7a27852203295 100644 (file)
@@ -122,6 +122,19 @@ public class TableDefinition<T> {
                                throw new IciqlException(e);\r
                        }\r
                }\r
+               \r
+               @Override\r
+               public int hashCode() {\r
+                       return columnName.hashCode();\r
+               }\r
+               \r
+               @Override\r
+               public boolean equals(Object o) {\r
+                       if (o instanceof FieldDefinition) {\r
+                               return o.hashCode() == hashCode();\r
+                       }\r
+                       return false;\r
+               }\r
        }\r
 \r
        public ArrayList<FieldDefinition> fields = Utils.newArrayList();\r
@@ -305,6 +318,7 @@ public class TableDefinition<T> {
                        classFields.addAll(Arrays.asList(superClass.getDeclaredFields()));\r
                }\r
 \r
+               Set<FieldDefinition> uniqueFields = new LinkedHashSet<FieldDefinition>();\r
                T defaultObject = Db.instance(clazz);\r
                for (Field f : classFields) {\r
                        // check if we should skip this field\r
@@ -390,9 +404,11 @@ public class TableDefinition<T> {
                                fieldDef.defaultValue = defaultValue;\r
                                fieldDef.enumType = enumType;\r
                                fieldDef.dataType = ModelUtils.getDataType(fieldDef);\r
-                               fields.add(fieldDef);\r
+                               uniqueFields.add(fieldDef);\r
                        }\r
                }\r
+               fields.addAll(uniqueFields);\r
+               \r
                List<String> primaryKey = Utils.newArrayList();\r
                int primitiveBoolean = 0;\r
                for (FieldDefinition fieldDef : fields) {\r