From 9e4799babb53626ccfea78bae9a3d58ceef9d258 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sat, 14 Jul 2012 16:09:52 -0400 Subject: [PATCH] Use the upgrade check to skip unnecessary table create statements --- src/com/iciql/Db.java | 6 ++++++ src/com/iciql/TableDefinition.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java index 16cf386..6187aba 100644 --- a/src/com/iciql/Db.java +++ b/src/com/iciql/Db.java @@ -279,6 +279,8 @@ public class Db { } // remove this model class from the table definition cache classMap.remove(modelClass); + // remove this model class from the upgrade checked cache + upgradeChecked.remove(modelClass); return rc; } @@ -395,6 +397,10 @@ public class Db { } return def; } + + boolean hasCreated(Class clazz) { + return upgradeChecked.contains(clazz); + } public synchronized void setDbUpgrader(DbUpgrader upgrader) { if (!upgrader.getClass().isAnnotationPresent(IQVersion.class)) { diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java index 1d9a98a..b6a670b 100644 --- a/src/com/iciql/TableDefinition.java +++ b/src/com/iciql/TableDefinition.java @@ -650,6 +650,9 @@ public class TableDefinition { db.upgradeTable(this); return this; } + if (db.hasCreated(clazz)) { + return this; + } SQLStatement stat = new SQLStatement(db); db.getDialect().prepareCreateTable(stat, this); IciqlLogger.create(stat.getSQL()); -- 2.39.5