aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/iciql/dialect/H2Dialect.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/iciql/dialect/H2Dialect.java')
-rw-r--r--src/com/iciql/dialect/H2Dialect.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/com/iciql/dialect/H2Dialect.java b/src/com/iciql/dialect/H2Dialect.java
new file mode 100644
index 0000000..e0a5035
--- /dev/null
+++ b/src/com/iciql/dialect/H2Dialect.java
@@ -0,0 +1,50 @@
+package com.iciql.dialect;
+
+import com.iciql.TableDefinition.IndexDefinition;
+import com.iciql.util.StatementBuilder;
+
+/**
+ * H2 database dialect.
+ */
+public class H2Dialect extends DefaultSQLDialect {
+
+ @Override
+ public boolean supportsMemoryTables() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsMerge() {
+ return true;
+ }
+
+ @Override
+ public String prepareCreateIndex(String schema, String table, IndexDefinition index) {
+ StatementBuilder buff = new StatementBuilder();
+ buff.append("CREATE ");
+ switch (index.type) {
+ case STANDARD:
+ break;
+ case UNIQUE:
+ buff.append("UNIQUE ");
+ break;
+ case HASH:
+ buff.append("HASH ");
+ break;
+ case UNIQUE_HASH:
+ buff.append("UNIQUE HASH ");
+ break;
+ }
+ buff.append("INDEX IF NOT EXISTS ");
+ buff.append(index.indexName);
+ buff.append(" ON ");
+ buff.append(table);
+ buff.append("(");
+ for (String col : index.columnNames) {
+ buff.appendExceptFirst(", ");
+ buff.append(col);
+ }
+ buff.append(")");
+ return buff.toString();
+ }
+} \ No newline at end of file