From f306672c6cfbc43a137751a736a1e5fa87314596 Mon Sep 17 00:00:00 2001
From: rbygrave
Date: Sat, 9 May 2015 00:59:59 +1200
Subject: [PATCH] No effective change - change newline char
---
.../config/dbplatform/AbstractDbEncrypt.java | 154 ++++++------
.../ebean/config/dbplatform/DB2Platform.java | 86 +++----
.../ebean/config/dbplatform/DbEncrypt.java | 80 +++----
.../config/dbplatform/DbEncryptFunction.java | 30 +--
.../ebean/config/dbplatform/H2DbEncrypt.java | 96 ++++----
.../ebean/config/dbplatform/H2Platform.java | 108 ++++-----
.../config/dbplatform/HsqldbPlatform.java | 94 ++++----
.../ebean/config/dbplatform/IdGenerator.java | 100 ++++----
.../avaje/ebean/config/dbplatform/IdType.java | 62 ++---
.../dbplatform/MsSqlServer2000Platform.java | 96 ++++----
.../dbplatform/MsSqlServer2005Platform.java | 158 ++++++------
.../ebean/config/dbplatform/MySqlBlob.java | 70 +++---
.../ebean/config/dbplatform/MySqlClob.java | 70 +++---
.../config/dbplatform/MySqlDbEncrypt.java | 72 +++---
.../config/dbplatform/MySqlPlatform.java | 134 +++++------
.../config/dbplatform/Oracle10DbEncrypt.java | 224 +++++++++---------
.../config/dbplatform/Oracle9Platform.java | 30 +--
.../config/dbplatform/Postgres8Platform.java | 134 +++++------
.../config/dbplatform/PostgresDbEncrypt.java | 72 +++---
19 files changed, 935 insertions(+), 935 deletions(-)
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java
index 980863bea..b65d1cabd 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/AbstractDbEncrypt.java
@@ -1,77 +1,77 @@
-package com.avaje.ebean.config.dbplatform;
-
-import java.sql.Types;
-
-/**
- * Base type for DB platform specific Encryption.
- *
- * DB specific classes that extend this need to set their specific encryption
- * functions for varchar, date and timestamp. If they are left null then that is
- * treated as though that data type can not be encrypted in the DB and will
- * instead use java client encryption.
- *
- *
- * @author rbygrave
- */
-public abstract class AbstractDbEncrypt implements DbEncrypt {
-
- /**
- * The encryption function for all String types (VARCHAR, CLOB, LONGVARCHAR,
- * CHAR).
- */
- protected DbEncryptFunction varcharEncryptFunction;
-
- /**
- * The encryption function for all Date types (java.sql.Date, Joda Date
- * types).
- */
- protected DbEncryptFunction dateEncryptFunction;
-
- /**
- * The encryption function for all Timestamp types (java.sql.Timestamp,
- * java.util.Date, java.util.Calendar, Joda DateTime types etc).
- */
- protected DbEncryptFunction timestampEncryptFunction;
-
- /**
- * Return the DB encryption function for the given JDBC type.
- *
- * Null is returned if DB encryption of the type is not supported.
- *
- */
- public DbEncryptFunction getDbEncryptFunction(int jdbcType) {
- switch (jdbcType) {
- case Types.VARCHAR:
- return varcharEncryptFunction;
- case Types.CLOB:
- return varcharEncryptFunction;
- case Types.CHAR:
- return varcharEncryptFunction;
- case Types.LONGVARCHAR:
- return varcharEncryptFunction;
-
- case Types.DATE:
- return dateEncryptFunction;
-
- case Types.TIMESTAMP:
- return timestampEncryptFunction;
-
- default:
- return null;
- }
- }
-
- /**
- * Return the DB stored type for encrypted properties.
- */
- public int getEncryptDbType() {
- return Types.VARBINARY;
- }
-
- /**
- * Generally encrypt function binding the data before the key (except h2).
- */
- public boolean isBindEncryptDataFirst() {
- return true;
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+import java.sql.Types;
+
+/**
+ * Base type for DB platform specific Encryption.
+ *
+ * DB specific classes that extend this need to set their specific encryption
+ * functions for varchar, date and timestamp. If they are left null then that is
+ * treated as though that data type can not be encrypted in the DB and will
+ * instead use java client encryption.
+ *
+ *
+ * @author rbygrave
+ */
+public abstract class AbstractDbEncrypt implements DbEncrypt {
+
+ /**
+ * The encryption function for all String types (VARCHAR, CLOB, LONGVARCHAR,
+ * CHAR).
+ */
+ protected DbEncryptFunction varcharEncryptFunction;
+
+ /**
+ * The encryption function for all Date types (java.sql.Date, Joda Date
+ * types).
+ */
+ protected DbEncryptFunction dateEncryptFunction;
+
+ /**
+ * The encryption function for all Timestamp types (java.sql.Timestamp,
+ * java.util.Date, java.util.Calendar, Joda DateTime types etc).
+ */
+ protected DbEncryptFunction timestampEncryptFunction;
+
+ /**
+ * Return the DB encryption function for the given JDBC type.
+ *
+ * Null is returned if DB encryption of the type is not supported.
+ *
+ */
+ public DbEncryptFunction getDbEncryptFunction(int jdbcType) {
+ switch (jdbcType) {
+ case Types.VARCHAR:
+ return varcharEncryptFunction;
+ case Types.CLOB:
+ return varcharEncryptFunction;
+ case Types.CHAR:
+ return varcharEncryptFunction;
+ case Types.LONGVARCHAR:
+ return varcharEncryptFunction;
+
+ case Types.DATE:
+ return dateEncryptFunction;
+
+ case Types.TIMESTAMP:
+ return timestampEncryptFunction;
+
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Return the DB stored type for encrypted properties.
+ */
+ public int getEncryptDbType() {
+ return Types.VARBINARY;
+ }
+
+ /**
+ * Generally encrypt function binding the data before the key (except h2).
+ */
+ public boolean isBindEncryptDataFirst() {
+ return true;
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java
index 7fd61ad40..6d76fa78a 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/DB2Platform.java
@@ -1,43 +1,43 @@
-package com.avaje.ebean.config.dbplatform;
-
-import java.sql.Types;
-
-import javax.sql.DataSource;
-
-import com.avaje.ebean.BackgroundExecutor;
-
-/**
- * DB2 specific platform.
- */
-public class DB2Platform extends DatabasePlatform {
-
- public DB2Platform() {
- super();
- this.name = "db2";
-
- // only support getGeneratedKeys with non-batch JDBC
- // so generally use SEQUENCE instead for H2
- this.sqlLimiter = new Db2SqlLimiter();
- this.dbIdentity.setSupportsGetGeneratedKeys(true);
- this.dbIdentity.setSupportsSequence(true);
-
- booleanDbType = Types.BOOLEAN;
- dbTypeMap.put(Types.REAL, new DbType("real"));
- dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
- dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 15));
-
- this.dbDdlSyntax.setIdentity("generated by default as identity");
- }
-
- /**
- * Return a DB2 specific sequence IdGenerator that supports batch fetching
- * sequence values.
- */
- @Override
- public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
- DataSource ds, String seqName, int batchSize) {
-
- return new DB2SequenceIdGenerator(be, ds, seqName, batchSize);
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+import java.sql.Types;
+
+import javax.sql.DataSource;
+
+import com.avaje.ebean.BackgroundExecutor;
+
+/**
+ * DB2 specific platform.
+ */
+public class DB2Platform extends DatabasePlatform {
+
+ public DB2Platform() {
+ super();
+ this.name = "db2";
+
+ // only support getGeneratedKeys with non-batch JDBC
+ // so generally use SEQUENCE instead for H2
+ this.sqlLimiter = new Db2SqlLimiter();
+ this.dbIdentity.setSupportsGetGeneratedKeys(true);
+ this.dbIdentity.setSupportsSequence(true);
+
+ booleanDbType = Types.BOOLEAN;
+ dbTypeMap.put(Types.REAL, new DbType("real"));
+ dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
+ dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 15));
+
+ this.dbDdlSyntax.setIdentity("generated by default as identity");
+ }
+
+ /**
+ * Return a DB2 specific sequence IdGenerator that supports batch fetching
+ * sequence values.
+ */
+ @Override
+ public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
+ DataSource ds, String seqName, int batchSize) {
+
+ return new DB2SequenceIdGenerator(be, ds, seqName, batchSize);
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java
index ac2295151..ab7671889 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncrypt.java
@@ -1,41 +1,41 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Defines DB encryption support for encrypting and decrypting data using DB
- * encryption features.
- *
- * As an alternative to using DB encryption you can encrypt/decrypt in java via
- * a special ScalarType but this has the limitation that you can't include that
- * property in query where clauses.
- *
- *
- * @author rbygrave
- */
-public interface DbEncrypt {
-
- // /**
- // * Return the SQL for decrypting a column returning a VARCHAR.
- // */
- // String getDecryptSql(String columnWithTableAlias);
- //
- // /**
- // * Return the DB function with bind variables used to encrypt a VARCHAR
- // * value.
- // */
- // String getEncryptBindSql();
-
- DbEncryptFunction getDbEncryptFunction(int jdbcType);
-
- /**
- * Return the DB type that encrypted Strings are stored in.
- *
- * This is VARCHAR for MySql and VARBINARY for most others.
- *
- */
- int getEncryptDbType();
-
- /**
- * Return true if the DB encrypt function binds the data before the key.
- */
- boolean isBindEncryptDataFirst();
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Defines DB encryption support for encrypting and decrypting data using DB
+ * encryption features.
+ *
+ * As an alternative to using DB encryption you can encrypt/decrypt in java via
+ * a special ScalarType but this has the limitation that you can't include that
+ * property in query where clauses.
+ *
+ *
+ * @author rbygrave
+ */
+public interface DbEncrypt {
+
+ // /**
+ // * Return the SQL for decrypting a column returning a VARCHAR.
+ // */
+ // String getDecryptSql(String columnWithTableAlias);
+ //
+ // /**
+ // * Return the DB function with bind variables used to encrypt a VARCHAR
+ // * value.
+ // */
+ // String getEncryptBindSql();
+
+ DbEncryptFunction getDbEncryptFunction(int jdbcType);
+
+ /**
+ * Return the DB type that encrypted Strings are stored in.
+ *
+ * This is VARCHAR for MySql and VARBINARY for most others.
+ *
+ */
+ int getEncryptDbType();
+
+ /**
+ * Return true if the DB encrypt function binds the data before the key.
+ */
+ boolean isBindEncryptDataFirst();
}
\ No newline at end of file
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncryptFunction.java b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncryptFunction.java
index d97972ab6..d3feea74a 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/DbEncryptFunction.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/DbEncryptFunction.java
@@ -1,15 +1,15 @@
-package com.avaje.ebean.config.dbplatform;
-
-public interface DbEncryptFunction {
-
- /**
- * Return the SQL for decrypting a column returning a VARCHAR.
- */
- String getDecryptSql(String columnWithTableAlias);
-
- /**
- * Return the DB function with bind variables used to encrypt a VARCHAR value.
- */
- String getEncryptBindSql();
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+public interface DbEncryptFunction {
+
+ /**
+ * Return the SQL for decrypting a column returning a VARCHAR.
+ */
+ String getDecryptSql(String columnWithTableAlias);
+
+ /**
+ * Return the DB function with bind variables used to encrypt a VARCHAR value.
+ */
+ String getEncryptBindSql();
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java
index 63c406712..589a7f8cc 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2DbEncrypt.java
@@ -1,48 +1,48 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * H2 encryption support via encrypt decrypt function.
- *
- * @author rbygrave
- */
-public class H2DbEncrypt extends AbstractDbEncrypt {
-
- public H2DbEncrypt() {
- this.varcharEncryptFunction = new H2VarcharFunction();
- this.dateEncryptFunction = new H2DateFunction();
- }
-
- /**
- * For H2 encrypt function returns false binding the key before the data.
- */
- public boolean isBindEncryptDataFirst() {
- return false;
- }
-
- private static class H2VarcharFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- // Hmmm, this looks ugly - checking with H2 Database folks.
- return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), "
- + columnWithTableAlias + ")))";
- }
-
- public String getEncryptBindSql() {
- return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(?))";
- }
-
- }
-
- private static class H2DateFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), "
- + columnWithTableAlias + "))),'yyyyMMdd')";
- }
-
- public String getEncryptBindSql() {
- return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(FORMATDATETIME(?,'yyyyMMdd')))";
- }
-
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * H2 encryption support via encrypt decrypt function.
+ *
+ * @author rbygrave
+ */
+public class H2DbEncrypt extends AbstractDbEncrypt {
+
+ public H2DbEncrypt() {
+ this.varcharEncryptFunction = new H2VarcharFunction();
+ this.dateEncryptFunction = new H2DateFunction();
+ }
+
+ /**
+ * For H2 encrypt function returns false binding the key before the data.
+ */
+ public boolean isBindEncryptDataFirst() {
+ return false;
+ }
+
+ private static class H2VarcharFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ // Hmmm, this looks ugly - checking with H2 Database folks.
+ return "TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), "
+ + columnWithTableAlias + ")))";
+ }
+
+ public String getEncryptBindSql() {
+ return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(?))";
+ }
+
+ }
+
+ private static class H2DateFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "PARSEDATETIME(TRIM(CHAR(0) FROM UTF8TOSTRING(DECRYPT('AES', STRINGTOUTF8(?), "
+ + columnWithTableAlias + "))),'yyyyMMdd')";
+ }
+
+ public String getEncryptBindSql() {
+ return "ENCRYPT('AES', STRINGTOUTF8(?), STRINGTOUTF8(FORMATDATETIME(?,'yyyyMMdd')))";
+ }
+
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java
index 124348095..e9df9c592 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java
@@ -1,54 +1,54 @@
-package com.avaje.ebean.config.dbplatform;
-
-import com.avaje.ebean.BackgroundExecutor;
-
-import javax.sql.DataSource;
-
-/**
- * H2 specific platform.
- */
-public class H2Platform extends DatabasePlatform {
-
- public H2Platform() {
- super();
- this.name = "h2";
- this.dbEncrypt = new H2DbEncrypt();
- // like ? escape'' not working in the latest version H2 so just using no
- // escape clause for now noting that backslash is an escape char for like in H2
- this.likeClause = "like ?";
-
- // only support getGeneratedKeys with non-batch JDBC
- // so generally use SEQUENCE instead of IDENTITY for H2
- this.dbIdentity.setIdType(IdType.SEQUENCE);
- this.dbIdentity.setSupportsGetGeneratedKeys(true);
- this.dbIdentity.setSupportsSequence(true);
- this.dbIdentity.setSupportsIdentity(true);
-
- this.openQuote = "\"";
- this.closeQuote = "\"";
-
- // H2 data types match default JDBC types
- // so no changes to dbTypeMap required
-
- this.dbDdlSyntax.setDropIfExists("if exists");
- this.dbDdlSyntax.setDisableReferentialIntegrity("SET REFERENTIAL_INTEGRITY FALSE");
- this.dbDdlSyntax.setEnableReferentialIntegrity("SET REFERENTIAL_INTEGRITY TRUE");
- this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
- }
-
- /**
- * Return a H2 specific sequence IdGenerator that supports batch fetching
- * sequence values.
- */
- @Override
- public IdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds,
- String seqName, int batchSize) {
-
- return new H2SequenceIdGenerator(be, ds, seqName, batchSize);
- }
-
- @Override
- protected String withForUpdate(String sql) {
- return sql + " for update";
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+import com.avaje.ebean.BackgroundExecutor;
+
+import javax.sql.DataSource;
+
+/**
+ * H2 specific platform.
+ */
+public class H2Platform extends DatabasePlatform {
+
+ public H2Platform() {
+ super();
+ this.name = "h2";
+ this.dbEncrypt = new H2DbEncrypt();
+ // like ? escape'' not working in the latest version H2 so just using no
+ // escape clause for now noting that backslash is an escape char for like in H2
+ this.likeClause = "like ?";
+
+ // only support getGeneratedKeys with non-batch JDBC
+ // so generally use SEQUENCE instead of IDENTITY for H2
+ this.dbIdentity.setIdType(IdType.SEQUENCE);
+ this.dbIdentity.setSupportsGetGeneratedKeys(true);
+ this.dbIdentity.setSupportsSequence(true);
+ this.dbIdentity.setSupportsIdentity(true);
+
+ this.openQuote = "\"";
+ this.closeQuote = "\"";
+
+ // H2 data types match default JDBC types
+ // so no changes to dbTypeMap required
+
+ this.dbDdlSyntax.setDropIfExists("if exists");
+ this.dbDdlSyntax.setDisableReferentialIntegrity("SET REFERENTIAL_INTEGRITY FALSE");
+ this.dbDdlSyntax.setEnableReferentialIntegrity("SET REFERENTIAL_INTEGRITY TRUE");
+ this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
+ }
+
+ /**
+ * Return a H2 specific sequence IdGenerator that supports batch fetching
+ * sequence values.
+ */
+ @Override
+ public IdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds,
+ String seqName, int batchSize) {
+
+ return new H2SequenceIdGenerator(be, ds, seqName, batchSize);
+ }
+
+ @Override
+ protected String withForUpdate(String sql) {
+ return sql + " for update";
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/HsqldbPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/HsqldbPlatform.java
index 1c9c4c198..dac3b8f5b 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/HsqldbPlatform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/HsqldbPlatform.java
@@ -1,47 +1,47 @@
-package com.avaje.ebean.config.dbplatform;
-
-import com.avaje.ebean.BackgroundExecutor;
-
-import javax.sql.DataSource;
-import java.sql.Types;
-
-/**
- * H2 specific platform.
- */
-public class HsqldbPlatform extends DatabasePlatform {
-
- public HsqldbPlatform() {
- super();
- this.name = "hsqldb";
- this.dbEncrypt = new H2DbEncrypt();
- this.dbIdentity.setIdType(IdType.IDENTITY);
- this.dbIdentity.setSupportsGetGeneratedKeys(true);
- this.dbIdentity.setSupportsSequence(true);
- this.dbIdentity.setSupportsIdentity(true);
-
- this.openQuote = "\"";
- this.closeQuote = "\"";
-
- // H2 data types match default JDBC types
- // so no changes to dbTypeMap required
- dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
-
- this.dbDdlSyntax.setDropIfExists("if exists");
- this.dbDdlSyntax.setDisableReferentialIntegrity("SET DATABASE REFERENTIAL INTEGRITY FALSE");
- this.dbDdlSyntax.setEnableReferentialIntegrity("SET DATABASE REFERENTIAL INTEGRITY TRUE");
- this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
- this.dbDdlSyntax.setIdentity("GENERATED BY DEFAULT AS IDENTITY (START WITH 1) ");
- }
-
- /**
- * Return a H2 specific sequence IdGenerator that supports batch fetching
- * sequence values.
- */
- @Override
- public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
- DataSource ds, String seqName, int batchSize) {
-
- return new H2SequenceIdGenerator(be, ds, seqName, batchSize);
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+import com.avaje.ebean.BackgroundExecutor;
+
+import javax.sql.DataSource;
+import java.sql.Types;
+
+/**
+ * H2 specific platform.
+ */
+public class HsqldbPlatform extends DatabasePlatform {
+
+ public HsqldbPlatform() {
+ super();
+ this.name = "hsqldb";
+ this.dbEncrypt = new H2DbEncrypt();
+ this.dbIdentity.setIdType(IdType.IDENTITY);
+ this.dbIdentity.setSupportsGetGeneratedKeys(true);
+ this.dbIdentity.setSupportsSequence(true);
+ this.dbIdentity.setSupportsIdentity(true);
+
+ this.openQuote = "\"";
+ this.closeQuote = "\"";
+
+ // H2 data types match default JDBC types
+ // so no changes to dbTypeMap required
+ dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
+
+ this.dbDdlSyntax.setDropIfExists("if exists");
+ this.dbDdlSyntax.setDisableReferentialIntegrity("SET DATABASE REFERENTIAL INTEGRITY FALSE");
+ this.dbDdlSyntax.setEnableReferentialIntegrity("SET DATABASE REFERENTIAL INTEGRITY TRUE");
+ this.dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
+ this.dbDdlSyntax.setIdentity("GENERATED BY DEFAULT AS IDENTITY (START WITH 1) ");
+ }
+
+ /**
+ * Return a H2 specific sequence IdGenerator that supports batch fetching
+ * sequence values.
+ */
+ @Override
+ public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
+ DataSource ds, String seqName, int batchSize) {
+
+ return new H2SequenceIdGenerator(be, ds, seqName, batchSize);
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/IdGenerator.java b/src/main/java/com/avaje/ebean/config/dbplatform/IdGenerator.java
index 32722f6f2..d7656a820 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/IdGenerator.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/IdGenerator.java
@@ -1,50 +1,50 @@
-package com.avaje.ebean.config.dbplatform;
-
-import com.avaje.ebean.Transaction;
-
-/**
- * Generates unique id's for objects. This occurs prior to the actual insert.
- *
- * Note that many databases have sequences or auto increment features. These can
- * be used rather than an IdGenerator and are different in that they occur
- * during an insert. IdGenerator is used to generate an id BEFORE the
- * actual insert.
- *
- */
-public interface IdGenerator {
-
- /**
- * The name of the default UUID generator.
- */
- static final String AUTO_UUID = "auto.uuid";
-
- /**
- * Return the name of the IdGenerator. For sequences this is the sequence
- * name.
- */
- String getName();
-
- /**
- * Return true if this is a DB sequence.
- */
- boolean isDbSequence();
-
- /**
- * return the next unique identity value.
- *
- * Note the transaction passed in can be null.
- *
- */
- Object nextId(Transaction transaction);
-
- /**
- * Is called prior to inserting OneToMany's as an indication that a number of
- * beans are likely to need id's shortly.
- *
- * Can be used as a performance optimisation to prefetch a number of Id's.
- * Especially when the allocateSize is very large.
- *
- */
- void preAllocateIds(int allocateSize);
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+import com.avaje.ebean.Transaction;
+
+/**
+ * Generates unique id's for objects. This occurs prior to the actual insert.
+ *
+ * Note that many databases have sequences or auto increment features. These can
+ * be used rather than an IdGenerator and are different in that they occur
+ * during an insert. IdGenerator is used to generate an id BEFORE the
+ * actual insert.
+ *
+ */
+public interface IdGenerator {
+
+ /**
+ * The name of the default UUID generator.
+ */
+ static final String AUTO_UUID = "auto.uuid";
+
+ /**
+ * Return the name of the IdGenerator. For sequences this is the sequence
+ * name.
+ */
+ String getName();
+
+ /**
+ * Return true if this is a DB sequence.
+ */
+ boolean isDbSequence();
+
+ /**
+ * return the next unique identity value.
+ *
+ * Note the transaction passed in can be null.
+ *
+ */
+ Object nextId(Transaction transaction);
+
+ /**
+ * Is called prior to inserting OneToMany's as an indication that a number of
+ * beans are likely to need id's shortly.
+ *
+ * Can be used as a performance optimisation to prefetch a number of Id's.
+ * Especially when the allocateSize is very large.
+ *
+ */
+ void preAllocateIds(int allocateSize);
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/IdType.java b/src/main/java/com/avaje/ebean/config/dbplatform/IdType.java
index a3203315f..c5868daae 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/IdType.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/IdType.java
@@ -1,31 +1,31 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * The types of Identity generation that can be defined.
- */
-public enum IdType {
-
- /**
- * Use a Database Identity (autoincrement) to generate the identity.
- */
- IDENTITY,
-
- /**
- * Use a Database sequence to generate the identity.
- *
- * Note: Some databases support getGeneratedKeys with sequences and this then
- * does not involve an extra statement to return the id.
- *
- */
- SEQUENCE,
-
- /**
- * Use an IdGenerator to generate the identity (prior to insert).
- *
- * Note: There is a IdGenerator for UUID's and it is automatically assigned to
- * id properties of type UUID.
- *
- */
- GENERATOR;
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * The types of Identity generation that can be defined.
+ */
+public enum IdType {
+
+ /**
+ * Use a Database Identity (autoincrement) to generate the identity.
+ */
+ IDENTITY,
+
+ /**
+ * Use a Database sequence to generate the identity.
+ *
+ * Note: Some databases support getGeneratedKeys with sequences and this then
+ * does not involve an extra statement to return the id.
+ *
+ */
+ SEQUENCE,
+
+ /**
+ * Use an IdGenerator to generate the identity (prior to insert).
+ *
+ * Note: There is a IdGenerator for UUID's and it is automatically assigned to
+ * id properties of type UUID.
+ *
+ */
+ GENERATOR;
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2000Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2000Platform.java
index 26c8923a8..afcb42a8b 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2000Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2000Platform.java
@@ -1,48 +1,48 @@
-package com.avaje.ebean.config.dbplatform;
-
-import java.sql.Types;
-
-/**
- * Microsoft SQL Server 2000 specific platform.
- *
- *
- * - supportsGetGeneratedKeys = false
- * - Use select @@IDENTITY to return the generated Id instead
- * - Uses LIMIT OFFSET clause
- * - Uses [ & ] for quoted identifiers
- *
- *
- */
-public class MsSqlServer2000Platform extends DatabasePlatform {
-
- public MsSqlServer2000Platform() {
- super();
- this.name = "mssqlserver2000";
- this.dbIdentity.setIdType(IdType.IDENTITY);
- this.dbIdentity.setSupportsGetGeneratedKeys(false);
- this.dbIdentity.setSelectLastInsertedIdTemplate("select @@IDENTITY as X");
- this.dbIdentity.setSupportsIdentity(true);
-
- this.openQuote = "[";
- this.closeQuote = "]";
-
- dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
-
- dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19));
- dbTypeMap.put(Types.REAL, new DbType("float(16)"));
- dbTypeMap.put(Types.DOUBLE, new DbType("float(32)"));
- dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
- dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28));
-
- dbTypeMap.put(Types.BLOB, new DbType("image"));
- dbTypeMap.put(Types.CLOB, new DbType("text"));
- dbTypeMap.put(Types.LONGVARBINARY, new DbType("image"));
- dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
-
- dbTypeMap.put(Types.DATE, new DbType("datetime"));
- dbTypeMap.put(Types.TIME, new DbType("datetime"));
- dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime"));
-
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+import java.sql.Types;
+
+/**
+ * Microsoft SQL Server 2000 specific platform.
+ *
+ *
+ * - supportsGetGeneratedKeys = false
+ * - Use select @@IDENTITY to return the generated Id instead
+ * - Uses LIMIT OFFSET clause
+ * - Uses [ & ] for quoted identifiers
+ *
+ *
+ */
+public class MsSqlServer2000Platform extends DatabasePlatform {
+
+ public MsSqlServer2000Platform() {
+ super();
+ this.name = "mssqlserver2000";
+ this.dbIdentity.setIdType(IdType.IDENTITY);
+ this.dbIdentity.setSupportsGetGeneratedKeys(false);
+ this.dbIdentity.setSelectLastInsertedIdTemplate("select @@IDENTITY as X");
+ this.dbIdentity.setSupportsIdentity(true);
+
+ this.openQuote = "[";
+ this.closeQuote = "]";
+
+ dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
+
+ dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19));
+ dbTypeMap.put(Types.REAL, new DbType("float(16)"));
+ dbTypeMap.put(Types.DOUBLE, new DbType("float(32)"));
+ dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
+ dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28));
+
+ dbTypeMap.put(Types.BLOB, new DbType("image"));
+ dbTypeMap.put(Types.CLOB, new DbType("text"));
+ dbTypeMap.put(Types.LONGVARBINARY, new DbType("image"));
+ dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
+
+ dbTypeMap.put(Types.DATE, new DbType("datetime"));
+ dbTypeMap.put(Types.TIME, new DbType("datetime"));
+ dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime"));
+
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2005Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2005Platform.java
index f7c1fc145..6dc722cdb 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2005Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MsSqlServer2005Platform.java
@@ -1,79 +1,79 @@
-package com.avaje.ebean.config.dbplatform;
-
-import java.sql.Types;
-
-/**
- * Microsoft SQL Server 2005 specific platform.
- *
- *
- * - supportsGetGeneratedKeys = true
- * - Uses LIMIT OFFSET clause
- * - Uses [ & ] for quoted identifiers
- *
- *
- */
-public class MsSqlServer2005Platform extends DatabasePlatform {
-
- public MsSqlServer2005Platform() {
- super();
- this.name = "mssqlserver2005";
- // effectively disable persistBatchOnCascade mode for SQL Server
- // due to lack of support for getGeneratedKeys in batch mode
- this.disallowBatchOnCascade = true;
- this.idInExpandedForm = true;
- this.sqlLimiter = new MsSqlServer2005SqlLimiter();
- this.dbDdlSyntax = new MsDdlSyntax();
- this.dbIdentity.setIdType(IdType.IDENTITY);
- this.dbIdentity.setSupportsGetGeneratedKeys(true);
- this.dbIdentity.setSupportsIdentity(true);
-
- this.openQuote = "[";
- this.closeQuote = "]";
-
- dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
-
- dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
- dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19));
- dbTypeMap.put(Types.REAL, new DbType("float(16)"));
- dbTypeMap.put(Types.DOUBLE, new DbType("float(32)"));
- dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
- dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28));
-
- dbTypeMap.put(Types.BLOB, new DbType("image"));
- dbTypeMap.put(Types.CLOB, new DbType("text"));
- dbTypeMap.put(Types.LONGVARBINARY, new DbType("image"));
- dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
-
- dbTypeMap.put(Types.DATE, new DbType("datetime"));
- dbTypeMap.put(Types.TIME, new DbType("datetime"));
- dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime"));
-
- }
-
- /**
- * MS SQL Server specific DDL Syntax.
- */
- public class MsDdlSyntax extends DbDdlSyntax {
-
- MsDdlSyntax() {
- this.identity = "identity(1,1)";
- this.dropKeyConstraints = true;
- }
-
- /**
- * Return some DDL to disable constraints on the given table.
- */
- public String dropKeyConstraintPrefix(String tableName, String fkName) {
- return "IF OBJECT_ID('"+fkName+"', 'F') IS NOT NULL";
- }
-
- /**
- * Return prefix text that goes before drop table.
- */
- public String dropTablePrefix(String tableName) {
- return "IF OBJECT_ID('"+tableName+"', 'U') IS NOT NULL ";
- }
-
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+import java.sql.Types;
+
+/**
+ * Microsoft SQL Server 2005 specific platform.
+ *
+ *
+ * - supportsGetGeneratedKeys = true
+ * - Uses LIMIT OFFSET clause
+ * - Uses [ & ] for quoted identifiers
+ *
+ *
+ */
+public class MsSqlServer2005Platform extends DatabasePlatform {
+
+ public MsSqlServer2005Platform() {
+ super();
+ this.name = "mssqlserver2005";
+ // effectively disable persistBatchOnCascade mode for SQL Server
+ // due to lack of support for getGeneratedKeys in batch mode
+ this.disallowBatchOnCascade = true;
+ this.idInExpandedForm = true;
+ this.sqlLimiter = new MsSqlServer2005SqlLimiter();
+ this.dbDdlSyntax = new MsDdlSyntax();
+ this.dbIdentity.setIdType(IdType.IDENTITY);
+ this.dbIdentity.setSupportsGetGeneratedKeys(true);
+ this.dbIdentity.setSupportsIdentity(true);
+
+ this.openQuote = "[";
+ this.closeQuote = "]";
+
+ dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
+
+ dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
+ dbTypeMap.put(Types.BIGINT, new DbType("numeric", 19));
+ dbTypeMap.put(Types.REAL, new DbType("float(16)"));
+ dbTypeMap.put(Types.DOUBLE, new DbType("float(32)"));
+ dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
+ dbTypeMap.put(Types.DECIMAL, new DbType("numeric", 28));
+
+ dbTypeMap.put(Types.BLOB, new DbType("image"));
+ dbTypeMap.put(Types.CLOB, new DbType("text"));
+ dbTypeMap.put(Types.LONGVARBINARY, new DbType("image"));
+ dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
+
+ dbTypeMap.put(Types.DATE, new DbType("datetime"));
+ dbTypeMap.put(Types.TIME, new DbType("datetime"));
+ dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime"));
+
+ }
+
+ /**
+ * MS SQL Server specific DDL Syntax.
+ */
+ public class MsDdlSyntax extends DbDdlSyntax {
+
+ MsDdlSyntax() {
+ this.identity = "identity(1,1)";
+ this.dropKeyConstraints = true;
+ }
+
+ /**
+ * Return some DDL to disable constraints on the given table.
+ */
+ public String dropKeyConstraintPrefix(String tableName, String fkName) {
+ return "IF OBJECT_ID('"+fkName+"', 'F') IS NOT NULL";
+ }
+
+ /**
+ * Return prefix text that goes before drop table.
+ */
+ public String dropTablePrefix(String tableName) {
+ return "IF OBJECT_ID('"+tableName+"', 'U') IS NOT NULL ";
+ }
+
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlBlob.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlBlob.java
index b73a734ff..7e171fc10 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlBlob.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlBlob.java
@@ -1,35 +1,35 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Support for blob, mediumblob or longblob selection based on the deployment
- * length.
- *
- * If no deployment length is defined longblob is used.
- *
- */
-public class MySqlBlob extends DbType {
-
- private static final int POWER_2_16 = 65536;
- private static final int POWER_2_24 = 16777216;
-
- public MySqlBlob() {
- super("blob");
- }
-
- @Override
- public String renderType(int deployLength, int deployScale) {
-
- if (deployLength >= POWER_2_24) {
- return "longblob";
- }
- if (deployLength >= POWER_2_16) {
- return "mediumblob";
- }
- if (deployLength < 1) {
- // length not explicitly defined
- return "longblob";
- }
- return "blob";
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Support for blob, mediumblob or longblob selection based on the deployment
+ * length.
+ *
+ * If no deployment length is defined longblob is used.
+ *
+ */
+public class MySqlBlob extends DbType {
+
+ private static final int POWER_2_16 = 65536;
+ private static final int POWER_2_24 = 16777216;
+
+ public MySqlBlob() {
+ super("blob");
+ }
+
+ @Override
+ public String renderType(int deployLength, int deployScale) {
+
+ if (deployLength >= POWER_2_24) {
+ return "longblob";
+ }
+ if (deployLength >= POWER_2_16) {
+ return "mediumblob";
+ }
+ if (deployLength < 1) {
+ // length not explicitly defined
+ return "longblob";
+ }
+ return "blob";
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlClob.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlClob.java
index 512a48ac8..9f8c5b098 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlClob.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlClob.java
@@ -1,35 +1,35 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Support for text, mediumtext or longtext selection based on the deployment
- * length.
- *
- * If no deployment length is defined longtext is used.
- *
- */
-public class MySqlClob extends DbType {
-
- private static final int POWER_2_16 = 65536;
- private static final int POWER_2_24 = 16777216;
-
- public MySqlClob() {
- super("text");
- }
-
- @Override
- public String renderType(int deployLength, int deployScale) {
-
- if (deployLength >= POWER_2_24) {
- return "longtext";
- }
- if (deployLength >= POWER_2_16) {
- return "mediumtext";
- }
- if (deployLength < 1) {
- // length not explicitly defined
- return "longtext";
- }
- return "text";
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Support for text, mediumtext or longtext selection based on the deployment
+ * length.
+ *
+ * If no deployment length is defined longtext is used.
+ *
+ */
+public class MySqlClob extends DbType {
+
+ private static final int POWER_2_16 = 65536;
+ private static final int POWER_2_24 = 16777216;
+
+ public MySqlClob() {
+ super("text");
+ }
+
+ @Override
+ public String renderType(int deployLength, int deployScale) {
+
+ if (deployLength >= POWER_2_24) {
+ return "longtext";
+ }
+ if (deployLength >= POWER_2_16) {
+ return "mediumtext";
+ }
+ if (deployLength < 1) {
+ // length not explicitly defined
+ return "longtext";
+ }
+ return "text";
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java
index 864cf9fa1..c8bf68ca2 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlDbEncrypt.java
@@ -1,36 +1,36 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * MySql aes_encrypt aes_decrypt based encryption support.
- *
- * @author rbygrave
- */
-public class MySqlDbEncrypt extends AbstractDbEncrypt {
-
- public MySqlDbEncrypt() {
- this.varcharEncryptFunction = new MyVarcharFunction();
- this.dateEncryptFunction = new MyDateFunction();
- }
-
- private static class MyVarcharFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "CONVERT(AES_DECRYPT(" + columnWithTableAlias + ",?) USING UTF8)";
- }
-
- public String getEncryptBindSql() {
- return "AES_ENCRYPT(?,?)";
- }
- }
-
- private static class MyDateFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "STR_TO_DATE(AES_DECRYPT(" + columnWithTableAlias + ",?),'%Y%d%m')";
- }
-
- public String getEncryptBindSql() {
- return "AES_ENCRYPT(DATE_FORMAT(?,'%Y%d%m'),?)";
- }
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * MySql aes_encrypt aes_decrypt based encryption support.
+ *
+ * @author rbygrave
+ */
+public class MySqlDbEncrypt extends AbstractDbEncrypt {
+
+ public MySqlDbEncrypt() {
+ this.varcharEncryptFunction = new MyVarcharFunction();
+ this.dateEncryptFunction = new MyDateFunction();
+ }
+
+ private static class MyVarcharFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "CONVERT(AES_DECRYPT(" + columnWithTableAlias + ",?) USING UTF8)";
+ }
+
+ public String getEncryptBindSql() {
+ return "AES_ENCRYPT(?,?)";
+ }
+ }
+
+ private static class MyDateFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "STR_TO_DATE(AES_DECRYPT(" + columnWithTableAlias + ",?),'%Y%d%m')";
+ }
+
+ public String getEncryptBindSql() {
+ return "AES_ENCRYPT(DATE_FORMAT(?,'%Y%d%m'),?)";
+ }
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java
index dc0c1e6b6..111782421 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java
@@ -1,67 +1,67 @@
-package com.avaje.ebean.config.dbplatform;
-
-import com.avaje.ebean.BackgroundExecutor;
-
-import javax.sql.DataSource;
-import java.sql.Types;
-
-/**
- * MySQL specific platform.
- *
- *
- * - supportsGetGeneratedKeys = true
- * - Uses LIMIT OFFSET clause
- * - Uses ` for quoted identifiers
- *
- *
- */
-public class MySqlPlatform extends DatabasePlatform {
-
- public MySqlPlatform() {
- super();
- this.name = "mysql";
- this.likeClause = "like ? escape''";
- this.selectCountWithAlias = true;
- this.dbEncrypt = new MySqlDbEncrypt();
-
- this.dbIdentity.setIdType(IdType.IDENTITY);
- this.dbIdentity.setSupportsGetGeneratedKeys(true);
- this.dbIdentity.setSupportsIdentity(true);
- this.dbIdentity.setSupportsSequence(false);
-
- this.openQuote = "`";
- this.closeQuote = "`";
-
- this.forwardOnlyHintOnFindIterate = true;
- this.booleanDbType = Types.BIT;
-
- dbTypeMap.put(Types.BIT, new DbType("tinyint(1) default 0"));
- dbTypeMap.put(Types.BOOLEAN, new DbType("tinyint(1) default 0"));
- dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime(6)"));
- dbTypeMap.put(Types.CLOB, new MySqlClob());
- dbTypeMap.put(Types.BLOB, new MySqlBlob());
- dbTypeMap.put(Types.BINARY, new DbType("binary", 255));
- dbTypeMap.put(Types.VARBINARY, new DbType("varbinary", 255));
-
- dbDdlSyntax.setMaxConstraintNameLength(64);
- dbDdlSyntax.setDisableReferentialIntegrity("SET FOREIGN_KEY_CHECKS=0");
- dbDdlSyntax.setEnableReferentialIntegrity("SET FOREIGN_KEY_CHECKS=1");
- dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
-
- }
-
- /**
- * Return null in case there is a sequence annotation.
- */
- @Override
- public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
- DataSource ds, String seqName, int batchSize) {
-
- return null;
- }
-
- @Override
- protected String withForUpdate(String sql) {
- return sql + " for update";
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+import com.avaje.ebean.BackgroundExecutor;
+
+import javax.sql.DataSource;
+import java.sql.Types;
+
+/**
+ * MySQL specific platform.
+ *
+ *
+ * - supportsGetGeneratedKeys = true
+ * - Uses LIMIT OFFSET clause
+ * - Uses ` for quoted identifiers
+ *
+ *
+ */
+public class MySqlPlatform extends DatabasePlatform {
+
+ public MySqlPlatform() {
+ super();
+ this.name = "mysql";
+ this.likeClause = "like ? escape''";
+ this.selectCountWithAlias = true;
+ this.dbEncrypt = new MySqlDbEncrypt();
+
+ this.dbIdentity.setIdType(IdType.IDENTITY);
+ this.dbIdentity.setSupportsGetGeneratedKeys(true);
+ this.dbIdentity.setSupportsIdentity(true);
+ this.dbIdentity.setSupportsSequence(false);
+
+ this.openQuote = "`";
+ this.closeQuote = "`";
+
+ this.forwardOnlyHintOnFindIterate = true;
+ this.booleanDbType = Types.BIT;
+
+ dbTypeMap.put(Types.BIT, new DbType("tinyint(1) default 0"));
+ dbTypeMap.put(Types.BOOLEAN, new DbType("tinyint(1) default 0"));
+ dbTypeMap.put(Types.TIMESTAMP, new DbType("datetime(6)"));
+ dbTypeMap.put(Types.CLOB, new MySqlClob());
+ dbTypeMap.put(Types.BLOB, new MySqlBlob());
+ dbTypeMap.put(Types.BINARY, new DbType("binary", 255));
+ dbTypeMap.put(Types.VARBINARY, new DbType("varbinary", 255));
+
+ dbDdlSyntax.setMaxConstraintNameLength(64);
+ dbDdlSyntax.setDisableReferentialIntegrity("SET FOREIGN_KEY_CHECKS=0");
+ dbDdlSyntax.setEnableReferentialIntegrity("SET FOREIGN_KEY_CHECKS=1");
+ dbDdlSyntax.setForeignKeySuffix("on delete restrict on update restrict");
+
+ }
+
+ /**
+ * Return null in case there is a sequence annotation.
+ */
+ @Override
+ public IdGenerator createSequenceIdGenerator(BackgroundExecutor be,
+ DataSource ds, String seqName, int batchSize) {
+
+ return null;
+ }
+
+ @Override
+ protected String withForUpdate(String sql) {
+ return sql + " for update";
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/Oracle10DbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/Oracle10DbEncrypt.java
index aea98e122..9cb458fe4 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/Oracle10DbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/Oracle10DbEncrypt.java
@@ -1,112 +1,112 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Oracle encryption support.
- *
- *
- * You will typically need to create your own encryption and decryption
- * functions similar to the example ones below.
- *
- *
- *
- *
- * // Remember your DB user needs execute privilege on DBMS_CRYPTO
- * // as well as your encryption and decryption functions
- *
- *
- * // This is an Example Encryption function only - please create your own.
- *
- * CREATE OR REPLACE FUNCTION eb_encrypt(data IN VARCHAR, key in VARCHAR) RETURN RAW IS
- *
- * encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
- *
- * BEGIN
- * RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'),
- * encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8') );
- * END;
- * /
- *
- *
- *
- * // This is an Example Decryption function only - please create your own.
- *
- * CREATE OR REPLACE FUNCTION eb_decrypt(data IN RAW, key IN VARCHAR) RETURN VARCHAR IS
- *
- * encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
- *
- * BEGIN
- * RETURN UTL_RAW.CAST_TO_VARCHAR2(DBMS_CRYPTO.DECRYPT
- * (data, encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8')));
- * END;
- * /
- *
- *
- * @author rbygrave
- */
-public class Oracle10DbEncrypt extends AbstractDbEncrypt {
-
- /**
- * Constructs the Oracle10DbEncrypt with default encrypt and decrypt stored procedures.
- */
- public Oracle10DbEncrypt() {
- this("eb_encrypt", "eb_decrypt");
- }
-
- /**
- * Constructs the Oracle10DbEncrypt specifying encrypt and decrypt stored procedures.
- *
- * @param encryptfunction the encrypt stored procedure
- * @param decryptfunction the decrypt stored procedure
- */
- public Oracle10DbEncrypt(String encryptfunction, String decryptfunction) {
-
- this.varcharEncryptFunction = new OraVarcharFunction(encryptfunction, decryptfunction);
- this.dateEncryptFunction = new OraDateFunction(encryptfunction, decryptfunction);
- }
-
- /**
- * VARCHAR encryption/decryption function.
- */
- private static class OraVarcharFunction implements DbEncryptFunction {
-
- private final String encryptfunction;
- private final String decryptfunction;
-
- public OraVarcharFunction(String encryptfunction, String decryptfunction) {
- this.encryptfunction = encryptfunction;
- this.decryptfunction = decryptfunction;
- }
-
- public String getDecryptSql(String columnWithTableAlias) {
- return decryptfunction + "(" + columnWithTableAlias + ",?)";
- }
-
- public String getEncryptBindSql() {
- return encryptfunction + "(?,?)";
- }
-
- }
-
- /**
- * DATE encryption/decryption function.
- */
- private static class OraDateFunction implements DbEncryptFunction {
-
- private final String encryptfunction;
- private final String decryptfunction;
-
- public OraDateFunction(String encryptfunction, String decryptfunction) {
- this.encryptfunction = encryptfunction;
- this.decryptfunction = decryptfunction;
- }
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "to_date(" + decryptfunction + "(" + columnWithTableAlias + ",?),'YYYYMMDD')";
- }
-
- public String getEncryptBindSql() {
- return encryptfunction + "(to_char(?,'YYYYMMDD'),?)";
- }
-
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Oracle encryption support.
+ *
+ *
+ * You will typically need to create your own encryption and decryption
+ * functions similar to the example ones below.
+ *
+ *
+ *
+ *
+ * // Remember your DB user needs execute privilege on DBMS_CRYPTO
+ * // as well as your encryption and decryption functions
+ *
+ *
+ * // This is an Example Encryption function only - please create your own.
+ *
+ * CREATE OR REPLACE FUNCTION eb_encrypt(data IN VARCHAR, key in VARCHAR) RETURN RAW IS
+ *
+ * encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
+ *
+ * BEGIN
+ * RETURN DBMS_CRYPTO.ENCRYPT(UTL_I18N.STRING_TO_RAW (data, 'AL32UTF8'),
+ * encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8') );
+ * END;
+ * /
+ *
+ *
+ *
+ * // This is an Example Decryption function only - please create your own.
+ *
+ * CREATE OR REPLACE FUNCTION eb_decrypt(data IN RAW, key IN VARCHAR) RETURN VARCHAR IS
+ *
+ * encryption_mode NUMBER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;
+ *
+ * BEGIN
+ * RETURN UTL_RAW.CAST_TO_VARCHAR2(DBMS_CRYPTO.DECRYPT
+ * (data, encryption_mode, UTL_I18N.STRING_TO_RAW(key, 'AL32UTF8')));
+ * END;
+ * /
+ *
+ *
+ * @author rbygrave
+ */
+public class Oracle10DbEncrypt extends AbstractDbEncrypt {
+
+ /**
+ * Constructs the Oracle10DbEncrypt with default encrypt and decrypt stored procedures.
+ */
+ public Oracle10DbEncrypt() {
+ this("eb_encrypt", "eb_decrypt");
+ }
+
+ /**
+ * Constructs the Oracle10DbEncrypt specifying encrypt and decrypt stored procedures.
+ *
+ * @param encryptfunction the encrypt stored procedure
+ * @param decryptfunction the decrypt stored procedure
+ */
+ public Oracle10DbEncrypt(String encryptfunction, String decryptfunction) {
+
+ this.varcharEncryptFunction = new OraVarcharFunction(encryptfunction, decryptfunction);
+ this.dateEncryptFunction = new OraDateFunction(encryptfunction, decryptfunction);
+ }
+
+ /**
+ * VARCHAR encryption/decryption function.
+ */
+ private static class OraVarcharFunction implements DbEncryptFunction {
+
+ private final String encryptfunction;
+ private final String decryptfunction;
+
+ public OraVarcharFunction(String encryptfunction, String decryptfunction) {
+ this.encryptfunction = encryptfunction;
+ this.decryptfunction = decryptfunction;
+ }
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return decryptfunction + "(" + columnWithTableAlias + ",?)";
+ }
+
+ public String getEncryptBindSql() {
+ return encryptfunction + "(?,?)";
+ }
+
+ }
+
+ /**
+ * DATE encryption/decryption function.
+ */
+ private static class OraDateFunction implements DbEncryptFunction {
+
+ private final String encryptfunction;
+ private final String decryptfunction;
+
+ public OraDateFunction(String encryptfunction, String decryptfunction) {
+ this.encryptfunction = encryptfunction;
+ this.decryptfunction = decryptfunction;
+ }
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "to_date(" + decryptfunction + "(" + columnWithTableAlias + ",?),'YYYYMMDD')";
+ }
+
+ public String getEncryptBindSql() {
+ return encryptfunction + "(to_char(?,'YYYYMMDD'),?)";
+ }
+
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/Oracle9Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/Oracle9Platform.java
index 7411e1747..8e484860d 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/Oracle9Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/Oracle9Platform.java
@@ -1,15 +1,15 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Since Ebean v2.2.0 Oracle9 is no different from Oracle10.
- *
- * This will be removed in the future.
- *
- */
-public class Oracle9Platform extends Oracle10Platform {
-
- public Oracle9Platform() {
- super();
- }
-
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Since Ebean v2.2.0 Oracle9 is no different from Oracle10.
+ *
+ * This will be removed in the future.
+ *
+ */
+public class Oracle9Platform extends Oracle10Platform {
+
+ public Oracle9Platform() {
+ super();
+ }
+
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/Postgres8Platform.java b/src/main/java/com/avaje/ebean/config/dbplatform/Postgres8Platform.java
index 3d42ced7d..512f24c4a 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/Postgres8Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/Postgres8Platform.java
@@ -1,67 +1,67 @@
-package com.avaje.ebean.config.dbplatform;
-
-import com.avaje.ebean.BackgroundExecutor;
-
-import javax.sql.DataSource;
-import java.sql.Types;
-
-/**
- * Postgres v8.3 specific platform.
- *
- * No support for getGeneratedKeys.
- *
- */
-public class Postgres8Platform extends DatabasePlatform {
-
- public Postgres8Platform() {
- super();
- this.name = "postgres";
- this.selectCountWithAlias = true;
- this.blobDbType = Types.LONGVARBINARY;
- this.clobDbType = Types.VARCHAR;
-
- this.dbEncrypt = new PostgresDbEncrypt();
-
- this.dbIdentity.setSupportsGetGeneratedKeys(false);
- this.dbIdentity.setIdType(IdType.SEQUENCE);
- this.dbIdentity.setSupportsSequence(true);
-
- this.columnAliasPrefix = "as c";
- this.openQuote = "\"";
- this.closeQuote = "\"";
-
- // dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
-
- dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
- dbTypeMap.put(Types.DOUBLE, new DbType("float"));
- dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
- dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 38));
-
- dbTypeMap.put(Types.BINARY, new DbType("bytea", false));
- dbTypeMap.put(Types.VARBINARY, new DbType("bytea", false));
-
- dbTypeMap.put(Types.BLOB, new DbType("bytea", false));
- dbTypeMap.put(Types.CLOB, new DbType("text"));
- dbTypeMap.put(Types.LONGVARBINARY, new DbType("bytea", false));
- dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
-
- dbDdlSyntax.setDropTableCascade("cascade");
- dbDdlSyntax.setDropIfExists("if exists");
-
- }
-
- /**
- * Create a Postgres specific sequence IdGenerator.
- */
- @Override
- public IdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds,
- String seqName, int batchSize) {
-
- return new PostgresSequenceIdGenerator(be, ds, seqName, batchSize);
- }
-
- @Override
- protected String withForUpdate(String sql) {
- return sql + " for update";
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+import com.avaje.ebean.BackgroundExecutor;
+
+import javax.sql.DataSource;
+import java.sql.Types;
+
+/**
+ * Postgres v8.3 specific platform.
+ *
+ * No support for getGeneratedKeys.
+ *
+ */
+public class Postgres8Platform extends DatabasePlatform {
+
+ public Postgres8Platform() {
+ super();
+ this.name = "postgres";
+ this.selectCountWithAlias = true;
+ this.blobDbType = Types.LONGVARBINARY;
+ this.clobDbType = Types.VARCHAR;
+
+ this.dbEncrypt = new PostgresDbEncrypt();
+
+ this.dbIdentity.setSupportsGetGeneratedKeys(false);
+ this.dbIdentity.setIdType(IdType.SEQUENCE);
+ this.dbIdentity.setSupportsSequence(true);
+
+ this.columnAliasPrefix = "as c";
+ this.openQuote = "\"";
+ this.closeQuote = "\"";
+
+ // dbTypeMap.put(Types.BOOLEAN, new DbType("bit default 0"));
+
+ dbTypeMap.put(Types.INTEGER, new DbType("integer", false));
+ dbTypeMap.put(Types.DOUBLE, new DbType("float"));
+ dbTypeMap.put(Types.TINYINT, new DbType("smallint"));
+ dbTypeMap.put(Types.DECIMAL, new DbType("decimal", 38));
+
+ dbTypeMap.put(Types.BINARY, new DbType("bytea", false));
+ dbTypeMap.put(Types.VARBINARY, new DbType("bytea", false));
+
+ dbTypeMap.put(Types.BLOB, new DbType("bytea", false));
+ dbTypeMap.put(Types.CLOB, new DbType("text"));
+ dbTypeMap.put(Types.LONGVARBINARY, new DbType("bytea", false));
+ dbTypeMap.put(Types.LONGVARCHAR, new DbType("text"));
+
+ dbDdlSyntax.setDropTableCascade("cascade");
+ dbDdlSyntax.setDropIfExists("if exists");
+
+ }
+
+ /**
+ * Create a Postgres specific sequence IdGenerator.
+ */
+ @Override
+ public IdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds,
+ String seqName, int batchSize) {
+
+ return new PostgresSequenceIdGenerator(be, ds, seqName, batchSize);
+ }
+
+ @Override
+ protected String withForUpdate(String sql) {
+ return sql + " for update";
+ }
+}
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java
index 65516b79b..e74111934 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresDbEncrypt.java
@@ -1,36 +1,36 @@
-package com.avaje.ebean.config.dbplatform;
-
-/**
- * Postgres pgp_sym_encrypt pgp_sym_decrypt based encryption support.
- *
- * @author rbygrave
- */
-public class PostgresDbEncrypt extends AbstractDbEncrypt {
-
- public PostgresDbEncrypt() {
- this.varcharEncryptFunction = new PgVarcharFunction();
- this.dateEncryptFunction = new PgDateFunction();
- }
-
- private static class PgVarcharFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "pgp_sym_decrypt(" + columnWithTableAlias + ",?)";
- }
-
- public String getEncryptBindSql() {
- return "pgp_sym_encrypt(?,?)";
- }
- }
-
- private static class PgDateFunction implements DbEncryptFunction {
-
- public String getDecryptSql(String columnWithTableAlias) {
- return "to_date(pgp_sym_decrypt(" + columnWithTableAlias + ",?),'YYYYMMDD')";
- }
-
- public String getEncryptBindSql() {
- return "pgp_sym_encrypt(to_char(?::date,'YYYYMMDD'),?)";
- }
- }
-}
+package com.avaje.ebean.config.dbplatform;
+
+/**
+ * Postgres pgp_sym_encrypt pgp_sym_decrypt based encryption support.
+ *
+ * @author rbygrave
+ */
+public class PostgresDbEncrypt extends AbstractDbEncrypt {
+
+ public PostgresDbEncrypt() {
+ this.varcharEncryptFunction = new PgVarcharFunction();
+ this.dateEncryptFunction = new PgDateFunction();
+ }
+
+ private static class PgVarcharFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "pgp_sym_decrypt(" + columnWithTableAlias + ",?)";
+ }
+
+ public String getEncryptBindSql() {
+ return "pgp_sym_encrypt(?,?)";
+ }
+ }
+
+ private static class PgDateFunction implements DbEncryptFunction {
+
+ public String getDecryptSql(String columnWithTableAlias) {
+ return "to_date(pgp_sym_decrypt(" + columnWithTableAlias + ",?),'YYYYMMDD')";
+ }
+
+ public String getEncryptBindSql() {
+ return "pgp_sym_encrypt(to_char(?::date,'YYYYMMDD'),?)";
+ }
+ }
+}