diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java
index 54073bd84..bf13fbed5 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/DatabasePlatform.java
@@ -6,6 +6,7 @@ import javax.sql.DataSource;
import com.avaje.ebean.BackgroundExecutor;
import com.avaje.ebean.Query;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -14,40 +15,61 @@ import org.slf4j.LoggerFactory;
*/
public class DatabasePlatform {
- /** The Constant logger. */
private static final Logger logger = LoggerFactory.getLogger(DatabasePlatform.class);
- /** The open quote used by quoted identifiers. */
+ /**
+ * The open quote used by quoted identifiers.
+ */
protected String openQuote = "\"";
- /** The close quote used by quoted identifiers. */
+ /**
+ * The close quote used by quoted identifiers.
+ */
protected String closeQuote = "\"";
- /** For limit/offset, row_number etc limiting of SQL queries. */
+ /**
+ * For limit/offset, row_number etc limiting of SQL queries.
+ */
protected SqlLimiter sqlLimiter = new LimitOffsetSqlLimiter();
- /** Mapping of JDBC to Database types. */
+ /**
+ * Mapping of JDBC to Database types.
+ */
protected DbTypeMap dbTypeMap = new DbTypeMap();
- /** DB specific DDL syntax. */
+ /**
+ * DB specific DDL syntax.
+ */
protected DbDdlSyntax dbDdlSyntax = new DbDdlSyntax();
- /** Defines DB identity/sequence features. */
+ /**
+ * Defines DB identity/sequence features.
+ */
protected DbIdentity dbIdentity = new DbIdentity();
- /** The JDBC type to map booleans to (by default). */
+ /**
+ * The JDBC type to map booleans to (by default).
+ */
protected int booleanDbType = Types.BOOLEAN;
- /** The JDBC type to map Blob to. */
+ /**
+ * The JDBC type to map Blob to.
+ */
protected int blobDbType = Types.BLOB;
- /** The JDBC type to map Clob to. */
+ /**
+ * The JDBC type to map Clob to.
+ */
protected int clobDbType = Types.CLOB;
- /** For Oracle treat empty strings as null. */
+ /**
+ * For Oracle treat empty strings as null.
+ */
protected boolean treatEmptyStringsAsNull;
- /** The name. */
+ /**
+ * The database platform name.
+ */
protected String name = "generic";
/**
@@ -57,6 +79,11 @@ public class DatabasePlatform {
*/
private static final char BACK_TICK = '`';
+ /**
+ * The like clause. Can be overridden to disable default escape character.
+ */
+ protected String likeClause = "like ?";
+
protected DbEncrypt dbEncrypt;
protected boolean idInExpandedForm;
@@ -299,4 +326,13 @@ public class DatabasePlatform {
return sql;
}
+
+ /**
+ * Returns the like clause used by this database platform.
+ *
+ * This may include an escape clause to disable a default escape character.
+ */
+ public String getLikeClause() {
+ return likeClause;
+ }
}
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 62572ad77..7adb7e27e 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/H2Platform.java
@@ -14,6 +14,7 @@ public class H2Platform extends DatabasePlatform {
super();
this.name = "h2";
this.dbEncrypt = new H2DbEncrypt();
+ this.likeClause = "like ? escape''";
// only support getGeneratedKeys with non-batch JDBC
// so generally use SEQUENCE instead of IDENTITY for H2
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 c89f06a6e..ae9a633b1 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/MySqlPlatform.java
@@ -20,6 +20,7 @@ public class MySqlPlatform extends DatabasePlatform {
public MySqlPlatform() {
super();
this.name = "mysql";
+ this.likeClause = "like ? escape''";
this.selectCountWithAlias = true;
this.dbEncrypt = new MySqlDbEncrypt();
diff --git a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java
index 5639894a9..a6d6bf1f9 100644
--- a/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java
+++ b/src/main/java/com/avaje/ebean/config/dbplatform/PostgresPlatform.java
@@ -23,6 +23,7 @@ public class PostgresPlatform extends DatabasePlatform {
public PostgresPlatform() {
super();
this.name = "postgres";
+ this.likeClause = "like ? escape''";
this.dbDdlSyntax = new PostgresDdlSyntax();
diff --git a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionRequest.java b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionRequest.java
index e38a7e872..0e11a5f82 100644
--- a/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionRequest.java
+++ b/src/main/java/com/avaje/ebeaninternal/api/SpiExpressionRequest.java
@@ -44,9 +44,14 @@ public interface SpiExpressionRequest {
* Return the ordered list of bind values for all expressions in this request.
*/
public ArrayList