]> source.dussan.org Git - iciql.git/commitdiff
Use the upgrade check to skip unnecessary table create statements
authorJames Moger <james.moger@gmail.com>
Sat, 14 Jul 2012 20:09:52 +0000 (16:09 -0400)
committerJames Moger <james.moger@gmail.com>
Sat, 14 Jul 2012 20:09:52 +0000 (16:09 -0400)
src/com/iciql/Db.java
src/com/iciql/TableDefinition.java

index 16cf38609bdbf5d8b91ba1daca4ceac03fb741aa..6187aba474bc44838dc001837ff36d7f01f166b4 100644 (file)
@@ -279,6 +279,8 @@ public class Db {
                }\r
                // remove this model class from the table definition cache\r
                classMap.remove(modelClass);\r
+               // remove this model class from the upgrade checked cache\r
+               upgradeChecked.remove(modelClass);\r
                return rc;\r
        }\r
 \r
@@ -395,6 +397,10 @@ public class Db {
                }\r
                return def;\r
        }\r
+       \r
+       <T> boolean hasCreated(Class<T> clazz) {\r
+               return upgradeChecked.contains(clazz);\r
+       }\r
 \r
        public synchronized void setDbUpgrader(DbUpgrader upgrader) {\r
                if (!upgrader.getClass().isAnnotationPresent(IQVersion.class)) {\r
index 1d9a98a29c876d353bda50cc2fad3fe23be501c3..b6a670b4f2c6b8656199dc93f6e6e99a0e23b41b 100644 (file)
@@ -650,6 +650,9 @@ public class TableDefinition<T> {
                        db.upgradeTable(this);\r
                        return this;\r
                }\r
+               if (db.hasCreated(clazz)) {\r
+                       return this;\r
+               }\r
                SQLStatement stat = new SQLStatement(db);\r
                db.getDialect().prepareCreateTable(stat, this);\r
                IciqlLogger.create(stat.getSQL());\r