summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2011-08-31 13:59:20 -0400
committerJames Moger <james.moger@gmail.com>2011-08-31 13:59:20 -0400
commit7b9af6d430452934da91760205861183c12c0bb4 (patch)
treea24230b874407e46f9fc794b02e2ab3e1b8b89c6 /src
parent69f2302c957a737564988aff2d9ae7b66287fe9d (diff)
downloadiciql-7b9af6d430452934da91760205861183c12c0bb4.tar.gz
iciql-7b9af6d430452934da91760205861183c12c0bb4.zip
Fixes to model generation. Fixes to default SQL dialect.
Diffstat (limited to 'src')
-rw-r--r--src/com/iciql/Db.java9
-rw-r--r--src/com/iciql/DbInspector.java6
-rw-r--r--src/com/iciql/ModelUtils.java11
-rw-r--r--src/com/iciql/SQLDialectDefault.java9
-rw-r--r--src/com/iciql/TableInspector.java2
-rw-r--r--src/com/iciql/util/GenerateModels.java7
6 files changed, 34 insertions, 10 deletions
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java
index af3c139..05d7f46 100644
--- a/src/com/iciql/Db.java
+++ b/src/com/iciql/Db.java
@@ -139,6 +139,15 @@ public class Db {
}
}
+ public static Db open(String url) {
+ try {
+ Connection conn = JdbcUtils.getConnection(null, url, null, null);
+ return new Db(conn);
+ } catch (SQLException e) {
+ throw new IciqlException(e);
+ }
+ }
+
public static Db open(String url, String user, String password) {
try {
Connection conn = JdbcUtils.getConnection(null, url, user, password);
diff --git a/src/com/iciql/DbInspector.java b/src/com/iciql/DbInspector.java
index 12124b8..acaceea 100644
--- a/src/com/iciql/DbInspector.java
+++ b/src/com/iciql/DbInspector.java
@@ -168,6 +168,12 @@ public class DbInspector {
rs = getMetaData().getTables(null, s, null, new String[] { "TABLE" });
while (rs.next()) {
String t = rs.getString("TABLE_NAME");
+ if (t.charAt(0) == '"') {
+ t = t.substring(1);
+ }
+ if (t.charAt(t.length() - 1) == '"') {
+ t = t.substring(0, t.length() - 1);
+ }
if (!t.equalsIgnoreCase(iciqlTables)) {
tables.add(new TableInspector(s, t, dateTimeClass));
}
diff --git a/src/com/iciql/ModelUtils.java b/src/com/iciql/ModelUtils.java
index 522da2a..678e7af 100644
--- a/src/com/iciql/ModelUtils.java
+++ b/src/com/iciql/ModelUtils.java
@@ -223,8 +223,15 @@ class ModelUtils {
// leading or trailing _
continue;
}
- className.append(Character.toUpperCase(chunk.charAt(0)));
- className.append(chunk.substring(1).toLowerCase());
+ String [] subchunks = StringUtils.arraySplit(chunk, ' ', false);
+ for (String subchunk : subchunks) {
+ if (subchunk.length() == 0) {
+ // leading or trailing space
+ continue;
+ }
+ className.append(Character.toUpperCase(subchunk.charAt(0)));
+ className.append(subchunk.substring(1).toLowerCase());
+ }
}
return className.toString();
}
diff --git a/src/com/iciql/SQLDialectDefault.java b/src/com/iciql/SQLDialectDefault.java
index 58848c1..193079f 100644
--- a/src/com/iciql/SQLDialectDefault.java
+++ b/src/com/iciql/SQLDialectDefault.java
@@ -177,14 +177,11 @@ public class SQLDialectDefault implements SQLDialect {
protected boolean prepareColumnDefinition(StatementBuilder buff, String dataType,
boolean isAutoIncrement, boolean isPrimaryKey) {
- boolean isIdentity = false;
- if (isAutoIncrement && isPrimaryKey) {
- buff.append(" IDENTITY");
- isIdentity = true;
- } else if (isAutoIncrement) {
+ buff.append(dataType);
+ if (isAutoIncrement) {
buff.append(" AUTO_INCREMENT");
}
- return isIdentity;
+ return false;
}
@Override
diff --git a/src/com/iciql/TableInspector.java b/src/com/iciql/TableInspector.java
index ce94c1b..9b67ac3 100644
--- a/src/com/iciql/TableInspector.java
+++ b/src/com/iciql/TableInspector.java
@@ -153,7 +153,7 @@ public class TableInspector {
col.isAutoIncrement = n.intValue() > 0;
}
} catch (SQLException s) {
- throw s;
+// throw s;
}
if (primaryKeys.size() == 1) {
if (col.name.equalsIgnoreCase(primaryKeys.get(0))) {
diff --git a/src/com/iciql/util/GenerateModels.java b/src/com/iciql/util/GenerateModels.java
index ce98105..1a6270f 100644
--- a/src/com/iciql/util/GenerateModels.java
+++ b/src/com/iciql/util/GenerateModels.java
@@ -133,7 +133,12 @@ public class GenerateModels {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
- Db db = Db.open(url, user, password.toCharArray());
+ Db db;
+ if (password == null) {
+ db = Db.open(url, user, (String) null);
+ } else {
+ db = Db.open(url, user, password.toCharArray());
+ }
DbInspector inspector = new DbInspector(db);
List<String> models = inspector.generateModel(schema, table, packageName, annotateSchema,
trimStrings);